Jump to content
🛡️FORUMS ARE IN READ-ONLY MODE Read more... ×
Sign in to follow this  
nuxil

Directions

Recommended Posts

hi..

i want unit A to setDir to "unit B or pos B" i come up with some messy code that needs to be simplefyed,, anyone got a great idea.. or is there a command i missed that does exactly this?

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

_Plpos = getpos player;

_cx = _Plpos select 0;

_cy = _Plpos select 1;

_cz = 0;

_ppos = getpos _plane;

_px = _Ppos select 0;

_py = _Ppos select 1;

_pz = _Ppos select 2;

_hyp = [_px,_py,0] distance [_cx,_cy,0];

_htt=0;

if ((_px < _cx) && (_py < _cy)) then {

_hk = [_px,_py,0] distance [_cx,_py,0];

_mk = [_cx,_py,0] distance [_cx,_cy,0];

_tanvink=( _mk / _hk );

_reelvink = atan _tanvink;

_htt = 90 - _reelvink;

};

if ((_px < _cx) && (_py > _cy)) then {

_hk = [_px,_py,0] distance [_cx,_py,0];

_mk = [_cx,_py,0] distance [_cx,_cy,0];

_tanvink=( _mk / _hk );

_reelvink = atan _tanvink;

_vx = 90 + _reelvink;

_htt = _vx;

};

if ((_px > _cx) && (_py > _cy)) then {

_hk = [_px,_py,0] distance [_px,_cy,0];

_mk = [_px,_cy,0] distance [_cx,_cy,0];

_tanvink=( _mk / _hk );

_reelvink = atan _tanvink;

_htt = 180 + _reelvink;

};

if ((_px > _cx) && (_py < _cy)) then {

_hk = [_px,_py,0] distance [_cx,_py,0];

_mk = [_cx,_py,0] distance [_cx,_cy,0];

_tanvink=( _mk / _hk );

_reelvink = atan _tanvink;

_htt = 270 + _reelvink;

};

_pane setdir _htt;

i dont want to use this messy code.. but if theres no other way i guess i just have to use it, is there anyone that know a simpler way to do it?

Share this post


Link to post
Share on other sites

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

_posa = getPos unitA;

_posb = getPos unitB;

_dir = ((_posb select 0)-(_posa select 0)) atan2 ((_posb select 1)-(_posa select 1));

unitA setDir _dir;

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  

×