简体   繁体   English

Unity2D:如何用鼠标旋转手臂

[英]Unity2D: How to rotate arm with mouse

i am currently working on a 2D project, i want to rotate an arm on my character, the arm is indeed a separate sprite, from the body of the player.我目前正在做一个 2D 项目,我想在我的角色上旋转手臂,手臂确实是一个独立的精灵,与玩家的身体分开。

I have a working script the rotate the arm perfectly but, the whole arm is rotating around a point in the middle of the arm, i want to rotate the arm from the shoulder, any ideas on how to do that?我有一个可以完美旋转手臂的工作脚本,但是,整个手臂都围绕手臂中间的一个点旋转,我想从肩部旋转手臂,关于如何做到这一点的任何想法?

The pivot point of your sprite is set to center rather than the end where the shoulder is located.精灵的枢轴点设置为中心而不是肩部所在的末端。 You can use the sprite editor to change the pivot.您可以使用精灵编辑器更改枢轴。 Below is a quick step by step on editing the pivot.下面是编辑枢轴的快速一步一步。 You can also find the information here -> https://docs.unity3d.com/Manual/SpriteEditor.html您也可以在这里找到信息 -> https://docs.unity3d.com/Manual/SpriteEditor.html

Editing Pivot on a Sprite在精灵上编辑枢轴

  • Select the 2D image you want to edit from the Project View .项目视图中选择要编辑的 2D 图像。 Note that you cannot edit a Sprite by selecting it in the Scene View.请注意,您无法通过在场景视图中选择来编辑精灵。
  • Click on the Sprite Editor button in the Texture Import Inspector and the Sprite Editor displays单击 Texture Import Inspector 中的Sprite Editor按钮,Sprite Editor 显示
  • Select the pivot drop down and select a your pivot location.选择枢轴下拉菜单并选择您的枢轴位置。

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM