The Daily Click ::. Forums ::. Klik Coding Help ::. Tails "Tails" getting air angle
 

Post Reply  Post Oekaki 
 

Posted By Message

xXBlazefirelpXx



Registered
  14/06/2010
Points
  45
18th November, 2010 at 20:48:02 -

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:
Image

Thanks in advance!

 
-----------------------------------------------

Benny Lindberg



Registered
  08/11/2010
Points
  54
18th November, 2010 at 21:03:12 -

Hiya!
Couldn't you just make a different animation for each direction tails is falling in?
Or did you want a separate "tail" object?

 
n/a

Jon Lambert

Administrator
Vaporware Master

Registered
  19/12/2004
Points
  8235

VIP MemberWii OwnerTDC Chat Super UserI am an April FoolSSBB 3265-4741-0937ACCF 3051-1173-8012360 Owner
18th November, 2010 at 21:23:13 -

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).

 
Sandwich Time!Whoo!

JoyCheck & KeyCheck Widgets
For easy implementation of customizable joystick and keyboard controls.
http://www.create-games.com/download.asp?id=8364

xXBlazefirelpXx



Registered
  14/06/2010
Points
  45
18th November, 2010 at 21:56:28 -

That did the trick. Thanks very much!

Edited by xXBlazefirelpXx

 
-----------------------------------------------

Jon Lambert

Administrator
Vaporware Master

Registered
  19/12/2004
Points
  8235

VIP MemberWii OwnerTDC Chat Super UserI am an April FoolSSBB 3265-4741-0937ACCF 3051-1173-8012360 Owner
18th November, 2010 at 22:14:06 -

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).
Image
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:

ATan2( <change in Y>,<change in X> )
returns the angle of a line.

EDIT: looks like you figured it out.

Edited by an Administrator

 
Sandwich Time!Whoo!

JoyCheck & KeyCheck Widgets
For easy implementation of customizable joystick and keyboard controls.
http://www.create-games.com/download.asp?id=8364

xXBlazefirelpXx



Registered
  14/06/2010
Points
  45
18th November, 2010 at 22:19:03 -

Thanks for the additional information Jon. It helped me understand it more.

 
-----------------------------------------------
   

Post Reply



 



Advertisement

Worth A Click