Jump to content
Sign in to follow this  
sakura_chan

Vector/Azimuth math help!

Recommended Posts

I need help with a script I'm working on. I'm trying to get the asimuth of an objects velocity in the same format as the getdir azimuth, meaning:

0 = north

90 = east

180 = south

270 = west

I've tried using vectordir and velocity with some success, but it only works if the object is traveling between 0-90 degrees.

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_a = vectordir _PLayer

_velx = _a select 0

_vely = _a select 1

_vecdir = asin (_vely / sqrt(_velx^2 + _vely^2))

here's what I've tried...can anyone help me? thanks!

******edit*********

figured it out!!!

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_a = velocity _PLayer

_velx = _a select 0

_vely = _a select 1

_vecdir = _velx atan2 _vely

? _vecdir < 0: _vecdir =  _vecdir + 360

should have read the script commands better  whistle.gif

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×