Hey there guys. I'm currently working on a SonicAdvance2 engine in MultimediaFusion2 and I can't seem to think of a decent method for getting an AIR Angle for me to set the Angle of tails sprite too. How do I achieve this?
In case I wasn't clear, this might help you understand what I want to do:
Well, you know his X velocity and his Y velocity, don't you? Just get an angle from that using ATan2, with his Y velocity (negative when falling because sin is negative at angles higher than 180 and lower than 360) and his X velocity (negative when moving left because cos is negative at angles greater than 90 and lower than 270). ATan2(YVel,XVel). For example, if Tails is moving right at a rate of 30 pixels per second, and also ascending at 30 pixels per second, you'd have ATan2(30,30), which returns an angle of 45 degrees. If you add 180 to that you'll get an angle opposite that (which is what you want as his tails face opposite his movement).
ATan2 is a function that returns the angle of a line. You put the Y length of the line as the first parameter, and the X length as the second parameter. If you want the angle of a line that goes 30 pixels right and 30 pixels up, you use ATan2(-30,30).
As seen in the picture a line that goes up 30 (negative) and right 30 (positive) will have an angle of 45 degrees. If you use the ATan2 formula in the expression editor, it will return that. I don't know how you're keeping track of Tails' speed, but if you're doing it as I do, you have them as two separate variables, which you will be able to just plug in to the function in the applicable spots, as explained before: