Master_Chief 0 Posted February 10, 2005 I need an equation that will find the the direction in degrees that the object is travelling based on its velocity. I don't want the direction that the object itself is facing though. Any help? I am trying to make a slideslip script for a car. Share this post Link to post Share on other sites
Guest [B.B.S.] T_D Posted February 10, 2005 Maybe something like this: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_obj = _this select 0 _velX = velocity _obj select 0 _velY = velocity _obj select 1 _dir = _velY Atan2 _velX hint format ["Direction of _obj: %1",_dir] exit no warranty Share this post Link to post Share on other sites
General Barron 0 Posted February 10, 2005 Easy enough to do with some trig: _vx = velocity _car select 0 _vy = velocity _car select 1 _dir = asin (_vy / sqrt(_vx^2 + _vy^2)) I might be mistaken on that, as I'm a bit tired atm. Share this post Link to post Share on other sites
Guest [B.B.S.] T_D Posted February 10, 2005 It is really the same, isn't it? Share this post Link to post Share on other sites
General Barron 0 Posted February 11, 2005 Whoops, guess you posted while I was typing . Yeah, mathematically it is the same, but [b.B.S.] T_D's solution is better, since it uses less commands and thus less cpu power. Share this post Link to post Share on other sites
KaRRiLLioN 0 Posted February 15, 2005 one minor thing, I think it's _velX Atan2 _velY. Also if you want to convert this to a normal 0-360 just do it like this: Quote[/b] ]_velX = (velocity _obj select 0) _velY = (velocity _obj select 1) _dir = _velX Atan2 _velY ?_dir < 0 : _dir = 360 + _dir It really doesn't matter if you do that since the result is the same, just in positives, rather than negatives. Share this post Link to post Share on other sites