OFPEC Forum
Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: icarus_uk on 31 Aug 2002, 20:30:34
-
Ok peoples. I have a looped setpos. The loop keeps one object relative to another.
Unfortunately if the independant object turns around then the dependant object does not move accordingly. Unfortunately if I do a setpos with a +10 on the Y axis it moves the object 10 metres north, and not 10 metres infront of the independant object which is what I want.
So how do I do this? Im thinking a GetDir, but its the maths thats eluding me.
-
I tested it. It works.
;_unit - The unit that is being "followed"
;_unit2 - _The object that is "following" the unit
;_rpos - direction relative to _unit1 _unit2 will be placed at (EXAMPLE: -179 through 180)
;_dis = distance to place _unit2 from _unit1
;
;Example: to have _unit2 allways stay 10meters in front of _unit1
;[unit1,unit2,0,10] exec "thisscript.sqs"
;
_unit = _this select 0
_unit2 = _this select 1
_rpos = _this select 2
_dis = _this select 3
#loop
_posx = getpos _unit select 0
_posy = getpos _unit select 1
_posz = getpos _unit select 2
_dir = getdir _unit
_unit2 setpos [_posx + ((sin (_dir + _rpos)) * _dis), _posy + ((cos (_dir + _rpos)) * _dis), _posz]
~0.1
goto "loop"
:)
-
f*ck me
been trying to do this for ages, but couldnt work out the maths (never been good with trig) thx toad :)