r/Unity3D•
woox13

Smoother Sprite 2D turret rotation (slerp?)

So I am making a turret, that targets enemy units as they are walking past the turret. Everything is in 2D (isometric view).

I have basically made it so the turret basically "follows"/rotates when a enemy unit walks past it, however once the turret needs to go back to next target next minion, it instantly jumps to that frame.

For example, I have sprites at 5 degree intervals, all the way around. So a minion walks by, and the turret rotates to 90 degrees. Then another enemy comes and is at 270 degrees, the tower will instantly FLIP to 270..I want it to run/have a smooth animation from 90-270 degrees.

So I am trying to use SLERP (with locked x and z axis), however slerp only rotates my static image...and that in random x/y/z directions even though I have them locked.

My question is what can I do to achieve the smoother animation above from a case such as 90 degrees to 270 degrees and not jump?

Posted Dec 2, 2012, 5:09 PM UTC

18
Loading comments…