- Home /
GameObject Rotation is always postive
Sorry if a post like this already exists (couldn't find it).
I'm trying to calculate how many flips the player has done on their bike but since I'm always getting a positive value I can't calculate it properly.
So this raises a few questions:
Is there a way to make the rotation go into the negative? If so, how?
How can I check if the rotation value falls below 0 and jumps to a value between 300-360?
So you know, I've been using "GameObject.transform.rotation.eulerAngles.z" to get the rotation value.
Thank you for your time and help.
Here is an alternate method of counting flips.
http://answers.unity3d.com/questions/651849/count-the-amount-of-flips-and-object-makes.html
Thank you. The code works, however one flips counts as two. Believe this to be down to there not being negative rotation.
There are some potential issues with the way you are doing things for general 3D rotations, but it will work for some situations. If you think it is working except for the problem you outline, then normalize the rotation into some framework. For example:
var angle = transform.eulerAngles.z;
if (angle > 180.0)
angle = angle - 360.0;
This way you will get rotations between -180 and 180.