Jump to content
Sign in to follow this  
squirt

Don't turn your back on me

Recommended Posts

How do i get the direction in which UnitA has to turn to see UnitB?

For the script line :

soldierA setdir (angel to soldierB)

much like CamSetTarget.. or generally speaking :

How do i get the direction (0° - 360°) of any given unit as seen from another unit confused.gif

               360

               |

        Q     |

               |

270<------X-------->90

               |

               |        

               |

              180

Like in what direction does X have to look to see Q? Q is changing position constantly, so trail and error wont work.

As i vaguely remember it may have to do with linear combination.. Thanks for reading anyhow smile.gif

Share this post


Link to post
Share on other sites

problem solved! I found it explained in my old notes

(Hey i already passed that test, so what do i still need to know this for ?!   tounge.gif )

</span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Code Sample </td></tr><tr><td id="CODE">

; FATNINJAKID - no rights reserved whatsoever!

; _angel as seen from _a!

_a= _this select 0

_b= _this select 1

_ax = (getpos _a select 0)

_ay= (getpos _a select 1)

_az= (getpos _a select 2)

_bx= (getpos _b select 0)

_by= (getpos _b select 1)

_bz= (getpos _b select 2)

; relative position

_abx = _bx -_ax

_aby= _by-_ay

_abz= _bz-_az

;vectors:

;_perpendicular = [0, 10]; 10  or whatever

;_connectionline = [_abx,_aby]

;Angel

_up= ( _abx+ 100* _aby)

_down =100* sqrt (_abx^2+_aby^2)

_coAb =_up/_down

_angel= acos _coAB

;-1<_coAB>1  !

?(_abx<0): _angel = 360 - _angel

<span id='postcolor'> biggrin.gif  biggrin.gif  biggrin.gif  biggrin.gif  biggrin.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  

×