Cumulative rotation - confusing me a little
Hopefully someone can point my brain in the right direction with this.
I have an actor, and when I hold a button down, I am getting it to rotate.
Once I let go of the button, I then want the actor to level out (sideways)..this works out as -90 (or 270) degrees.
This is all well and good if I only do a single rotation and let go, and it looks great.
When I hold the button for a number of rotation though, the rotation seens to be cumulative though. So when I let go of the button, and I tell the actor to go back to the level -90 degrees, it spins back round however many rotations I did untill it gets back there rather then just going back to the nearest version of being levelled out.
Is there a funky maths way of doing this.. or will I have to stick a load of "if" statements in my level out rule.
so
if rotation < -360 then rotate to -90
if rotation <-720 then rotate to -450
and so on and so forth
etc etc
I have an actor, and when I hold a button down, I am getting it to rotate.
Once I let go of the button, I then want the actor to level out (sideways)..this works out as -90 (or 270) degrees.
This is all well and good if I only do a single rotation and let go, and it looks great.
When I hold the button for a number of rotation though, the rotation seens to be cumulative though. So when I let go of the button, and I tell the actor to go back to the level -90 degrees, it spins back round however many rotations I did untill it gets back there rather then just going back to the nearest version of being levelled out.
Is there a funky maths way of doing this.. or will I have to stick a load of "if" statements in my level out rule.
so
if rotation < -360 then rotate to -90
if rotation <-720 then rotate to -450
and so on and so forth
etc etc
Comments
My initial rotation is just using "rotate". But my "come out of rotation" rule was using an interpolate.
Replaced that with a rotate to angle, and all is well with the world
I find sometimes it's hard not to over think a problem.