0

跳跃时我的gameObject不旋转。我用于GetComponent().rotation = Quaternion.identity;旋转,但gameObject仍然不旋转。问题是什么?以及如何调整旋转速度?这是我的跳转脚本:

4

2 回答 2

1

Quaternion.identity表示无旋转 {0,0,0,0},每当调用此代码块时,游戏对象的旋转将成为标准旋转值。

如果这是故意的并且游戏对象的旋转不是 {0,0,0,0} 那么也许您正在其他地方修改旋转?

于 2015-08-27T12:51:40.947 回答
1
GetComponent().rotation = Quaternion.identity; 

这条线有几个问题。首先,只需使用 transform.rotation... 此处无需调用 GetComponent()。此外,Quaternion.identity只是“零”旋转。您实际上想在这里应用什么样的轮换,因为您不应该看到任何使用身份的东西。

http://docs.unity3d.com/ScriptReference/Quaternion-identity.html

要应用真正的旋转,请使用类似的东西(其中“速度”是一个浮点变量,您可以在其中设置希望立方体旋转的速度):

transform.Rotate(Vector3.up, speed * Time.deltaTime);
于 2015-08-27T12:52:10.657 回答