OFPEC Forum
Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: dmakatra on 06 Jun 2007, 22:55:04
-
Long time no see to you all. Now ol' Armsty pretty much got raped by the Swedish business world and lost his summer employment. That means Armsty has way too much time on his hands. To keep him occupied he'll either have to resort to drugs, or start doing some editing again. Same thing different names anyway, is it not?
Not only am I very, very rusty, I have also put myself in something of a conumdrum. Involving maths. Should be easy for someone who hasn't had his head in a bucket the past fifteen years though.
Right. So basically, I have Unit A. What I want to find out the position of Unit A, say, 10 metres behind him. Now, all I've come up with is that I have to getDir Unit A, then subtract 180 so I get the opposite direction of the direction Unit A is facing (i.e. directly behind him). Then I have to use this value combined with Unit A's getPos-values and the number 10 to find what I want. I have no idea how though. Could someone help me out here? I'll kiss your feet digitally.
Hepp Hepp!
/Armsty
-
sin and cos are your friends. they won't buy you drugs, but they will solve this problem.
_x = getpos unita select 0
_y = getpos unita select 1
_dir = getdir unita
_distance = 10
_point_you_want = [_x + (10*sin(_dir-180)), _y + (10*cos(_dir-180))]
foot kissing not necessary, it's just nice to see you back.
-
You are missing an small detail there :P
_unit = _this select 0
_dir = getdir _unit
_distance = 10
_x = getpos _unit select 0
_y = getpos _unit select 1
_almost_point_you_want = [_x + (10*sin(_dir-180)), _y + (10*cos(_dir-180))]
;The previous point will be not 10m at the back of the unit unless at sea level ...
_sea = "EmptyDetector" camCreate [0,0,0]
_sea setPos [_x, _y, 0]
_asl1 = _sea distance _unit
_ground = "logic" camCreate [_almost_point_you_want select 0, _almost_point_you_want select 1, 0]
_als2 = _ground distance _sea
deleteVehicle _sea
deleteVehicle _ground
_z = _asl1 - _asl2
_point_you_really_want = [_almost_point_you_want select 0, _almost_point_you_want select 1, _z]
:P
EDIT:
:P
-
Cheers to you both! I'll check this out tomorrow afternoon. :)
-
Worked like a charm. Kisses to both of you. :D
-
has it been so long you've forgotten how to modify posts? mmm? :whistle:
as an aside, your avatar isn't displaying mate - we all miss syd.