YesNoOk
avatar

Auto Facing (Read 333 times)

Started by Guillier, June 25, 2009, 03:57:53 pm
Share this topic:
Auto Facing
#1  June 25, 2009, 03:57:53 pm
  • avatar
  • **
Hi I Need Help.
It's about auto facing which will turn the helper to face the direction his going to according to his velocity.
I have a missile helper that follows the opponent with no fix velocity since he will follow the opponent.
Like when my helper have a velocity of x=9,y=-9, he will face to upright direction.
Please help.
thanks.   :)
Re: Auto Facing
#2  June 25, 2009, 05:40:31 pm
  • ******
  • [E]
    • Mexico
[State ProjEsp ]
Type      = AngleDraw
trigger1   = 1
value          = atan((-1* vel Y) / (vel X))*57.2957795
scale          = 1.0,1.0
Re: Auto Facing
#3  June 25, 2009, 06:20:27 pm
  • **
[State ProjEsp ]
Type      = AngleDraw
trigger1   = 1
value          = atan((-1* vel Y) / (vel X))*57.2957795
scale          = 1.0,1.0


This will only work if you use positive X velocities because atan is limited to values between Pi/2 (90°) and -Pi/2 (-90°).
For negative velocities you have to extend it:
[mcode]value = -atan(vel Y/vel X)*57.2957795 + 180*(Vel X < 0)[/mcode]

Also keep in mind that you will get warnings if vel X = 0 because of division by zero.
Latest Creation: SSBB Assist Trophies
Re: Auto Facing
#4  June 26, 2009, 12:38:37 pm
  • avatar
  • **
Problem solved.  :o
Thank you very much for help.  :D
Thanks a lot. :D