How to stop rotation?

Hi there,

I have a bunch of enemies in my 2D shooter that I want to spin on to the screen and then stop at rotation points 0, 0, 0. I know how to do this with time… but how do I stop rotation at a particular angle, rather than “stop rotating around Z after 2 seconds”? This would give me much more control.

I’d also use the WaitForSeconds while the enemies shoot, then rotate off the screen again. I have looked at Rotate.toward but can’t work it out properly.

Any help muchly appreciated!

you could check the eulerAngle.z each frame and if it’s within your range, stop updating the rotation. The more direct approach would be to rotate to a given angle in the first place, rather than rotating by time.

For this type of thing I usually use iTween, which makes it one line of code.

iTween.RotateTo(gameObject, eulerAngles, Time);