Reputation: 401
I have the following code:
private void Update()
{
Vector3 currRotation = transform.localRotation.eulerAngles;
currRotation = new Vector3(currRotation.x + 2, currRotation.y, currRotation.z);
transform.localRotation = Quaternion.Euler(currRotation);
}
Whatever the script is attached to will rotate around the X-axis.
I'm not interested in using other ways to rotate the object as this is a small model of how I'm handling the rotation of an object in an application I'm creating.
when I add the "+1" to the Y and Z coordinates it continues to rotate, however, when it's on the X it behaves differently. When X passes the 90 degree mark and is set it appears to subtract from 90 instead of continue to add it.
So when I set X to 94, the next time I read X it's 86.
Why does it do this?
Upvotes: 0
Views: 57
Reputation: 2558
The problem your seeing is an issue due to Gimbal Lock. Check out the following: https://answers.unity.com/questions/573035/avoiding-gimbal-lock.html
Upvotes: 1