Reverse rotations problems...

Hi,

I’ve been trying to figure this out and I just can’t get it to work, so hopefully one of you guys can get it working.

All I need to do is be able to reverse rotations. Example: When a storm starts I have the wind zone rotate to 180 degrees, then stop once it reaches 180. Once a storm has cleared up I want the winds rotation to gradually return to 0 degrees, but this requires reverse rotations. If I use the normal transform.rotate I get the gimbal lock problem. If anyone knows how that’d be great, I just need an example that’s all.

Also I’ve tried using inverse quaternions and I’m not sure how to properly set up my object so this could also be an approach.

windZone.transform.rotation = Quaternion.Inverse(target.rotation);

I’m using the below to lock the rotation once reached with an if statement, which I read could cause problems, but I’m not sure if they’re related to the gimbal lock.

windZone.transform.eulerAngles.y = 0;

If anyone has any solutions I’m willing to try anything and I’ll be sure to mark as answered if it works.

You could Mathf.Lerp or the Mathf.LerpAngle the rotation value back. I have not used LerpAngle myself ever, always done it with just Lerp.

Thanks everyone for the answers, but I ended up finding a better solution after much searching and trial and error.

It was as simple as transform.Rotate(-Vector3.up * “Whatever”) which worked great and did exactly what I needed.