user5272788
user5272788

Reputation:

My gameObject does not rotate while jumping

My gameObject does not rotate while jumping. I used GetComponent().rotation = Quaternion.identity; for rotation but the gameObject still does not rotate. What is the problem? And how do I adjust the speed of the rotation? Here's my jump script:

Upvotes: 0

Views: 83

Answers (2)

slumtrimpet
slumtrimpet

Reputation: 3267

GetComponent().rotation = Quaternion.identity; 

Couple issues with this line. First off, just use transform.rotation... no need to call GetComponent() here. Also, Quaternion.identity is just the 'zero' rotation. What kind of rotation are you actually trying to apply here because you shouldn't see anything using identity.

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

To apply real rotation use something like (where "speed" is a float var where you can set how fast you want your cube to rotate):

transform.Rotate(Vector3.up, speed * Time.deltaTime);

Upvotes: 1

CakeCommander
CakeCommander

Reputation: 78

Quaternion.identity means no rotation {0,0,0,0}, whenever this code block is called the gameObject's rotation will become the standard rotation value.

If this was intentional and the rotation of the gameObject is not {0,0,0,0} then perhaps you are modifying the rotation elsewhere?

Upvotes: 1

Related Questions