我的游戏对象在跳跃时不旋转
My gameObject does not rotate while jumping
我的gameObject
跳跃时不旋转。我使用 GetComponent().rotation = Quaternion.identity;
进行旋转,但 gameObject
仍然不旋转。问题是什么?以及如何调整旋转速度?这是我的跳转脚本:
Quaternion.identity表示没有旋转{0,0,0,0},每当调用此代码块时,游戏对象的旋转将成为标准旋转值。
如果这是故意的并且游戏对象的旋转不是 {0,0,0,0} 那么也许您正在其他地方修改旋转?
GetComponent().rotation = Quaternion.identity;
这行有几个问题。首先,只需使用 transform.rotation... 无需在此处调用 GetComponent()。此外,Quaternion.identity
只是 'zero' 旋转。你实际上想在这里应用什么样的轮换,因为你不应该看到任何使用身份的东西。
http://docs.unity3d.com/ScriptReference/Quaternion-identity.html
要应用真正的旋转,请使用类似的东西(其中 "speed" 是一个浮点变量,您可以在其中设置您希望立方体旋转的速度):
transform.Rotate(Vector3.up, speed * Time.deltaTime);
我的gameObject
跳跃时不旋转。我使用 GetComponent().rotation = Quaternion.identity;
进行旋转,但 gameObject
仍然不旋转。问题是什么?以及如何调整旋转速度?这是我的跳转脚本:
Quaternion.identity表示没有旋转{0,0,0,0},每当调用此代码块时,游戏对象的旋转将成为标准旋转值。
如果这是故意的并且游戏对象的旋转不是 {0,0,0,0} 那么也许您正在其他地方修改旋转?
GetComponent().rotation = Quaternion.identity;
这行有几个问题。首先,只需使用 transform.rotation... 无需在此处调用 GetComponent()。此外,Quaternion.identity
只是 'zero' 旋转。你实际上想在这里应用什么样的轮换,因为你不应该看到任何使用身份的东西。
http://docs.unity3d.com/ScriptReference/Quaternion-identity.html
要应用真正的旋转,请使用类似的东西(其中 "speed" 是一个浮点变量,您可以在其中设置您希望立方体旋转的速度):
transform.Rotate(Vector3.up, speed * Time.deltaTime);