Reset angle using interp
Hey - I'm working on a game where I have an actor that rotates around another actor. On game fail, I'd like the orbiting actor to interp back to a determined angle, it's starting position. I'm running into the issue of gamesalad's implement of angles, namely that it flips at 180 degrees - if the actor is less than half way round, it behaves fine, if it has gone past the half way point, it'll rotate all the way through 360 until it gets back to 0, which looks a bit silly.
I know I'm supposed to use this formula - [ (('new angle'+180)%360)-180 ] HOWEVER, since my orbiting actor can rotate around the actor multiple times, the attributes I have for angles accumulate - which means that if I plug in that number, and the orbiting actor has done three orbits, then it'll have to interp all the way back through those angles.
Hopefully that actually makes sense....
Don't suppose anyone has run into this issue before? I could just use a change attribute and have it all done instantly, which solves the problem, but just, you know, doesn't look great.
Comments
Not sure how your orbiting actor is set up but I'd be tempted to not use angle values to determine sin and cos values, I'd just use something like time or an interpolated value, so avoiding the 180 to -180 angle flip issue.
P.S. if you use %360 the angle can't accumulate, it resets on every rotation, so 8 rotations + 40° is still just 40° rather than 2920°.
Thanks @socks - I couldn't quite get the interp value to look as smooth as the rotate behaviour - I also need to be able to modify the rotation speed in game, which just gets a bit tricky (in my head) to do when you're reducing the interp duration rather than increasing the speed.
I just cheated and hid the orbiting actor during reset, since it'd meant to have been 'destroyed' on failed anyway. Cheaty cheaty but looks okay.