I dont know how to get this done…
I rotate a object around its Y axis.(via mouse but that is not important)
I have a java script on that object that reads the actual localRotation.eulerAngles.y.
I need to know how often it is rotated around its axis.
but if it gets over 359 it sets itselfe to 0 and backwards.
If the var could get over 360 degree or under -360 that would help…
hah I found a solution!!!
In my case I convert the eulerAngles to numbers from 0 to 99. but it can also be done if using degrees.
var diffOfRot : int = 0;
if(oldRotOfDial > newRotOfDial)
{
diffOfRot = oldRotOfDial - newRotOfDial;
if(diffOfRot > 50)
if(fullRotations != 0)
fullRotations++;
}
if(oldRotOfDial < newRotOfDial)
{
diffOfRot = newRotOfDial - oldRotOfDial;
if(diffOfRot > 50)
if(fullRotations != -4)
fullRotations--;
}
I simply make in my update function a var at the top that saves the current rotation before it will be changed in this update function.
and because the rotation goes from 359 to 0 or 0 to 359 ( in my case from 99 to 0 and 0 to 99) I can make these if conditions that calculate if the difference is too high then a full rotation has happen and I can also see in which direction it was rotated.
still there is a bug if the rotation starts at 0 and I would rotate backwards then it would say I rotated -1 but in my case this does not bother me.