我的gameObject不会在跳跃时旋转。我使用GetComponent().rotation = Quaternion.identity;进行旋转,但是gameObject仍然不旋转。有什么问题吗?我如何调整旋转的速度?这是我的跳槽脚本:
发布于 2015-08-27 12:51:40
Quaternion.identity意味着没有旋转{0,0,0,0},每当这个代码块被调用时,游戏对象的旋转就会成为标准的旋转值。
如果这是有意的,并且gameObject的旋转不是{0,0,0,0},那么您可能正在修改其他地方的旋转吗?
发布于 2015-08-27 12:52:10
GetComponent().rotation = Quaternion.identity; 这条线有几个问题。首先,用transform.rotation.这里不需要调用GetComponent()。而且,Quaternion.identity只是‘零’旋转。你在这里申请的是什么样的旋转,因为你不应该看到任何使用身份的东西。
http://docs.unity3d.com/ScriptReference/Quaternion-identity.html
要应用真正的旋转,请使用类似的方法(其中“速度”是浮动变量,您可以在其中设置希望立方体旋转的速度):
transform.Rotate(Vector3.up, speed * Time.deltaTime);https://stackoverflow.com/questions/32249053
复制相似问题