OFPEC Forum
Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: bedges on 24 Feb 2005, 16:58:12
-
i have looked in the faq, and i see a couple on setdir and distance between - close but no cigar. i know this has been asked before, so apologies....
i need to know the trig involved in finding the degree heading between two objects. the purpose is to sidestep the dowatch getpos object route and force a setdir relative to the player.
i know it's something to do with subtracting the x and y values of the target from the source, and then some sin/cos doohicky... i dunno, maths was never my strong point.
cheers meantime :)
-
Try:
(x2-x1) atan2 (y2-y1)
where X is result of getPos select 0 on the two objects
and Y is the result of getPos select 1 on the two objects
The resulting angle is the direction of object 2 from object 1 in degrees, in the range -180 to +180.
-
There are a couple of trig guides in the Ed Depot, and every now and again a kind soul like THobson posts something like this in the forums.
I also have a feeling somebody made a function that does this. It is the sort of thing functions are for.
-
y'know, i've just finished putting a textual head-nod to you (THobson) at the top of these scripts i'm working on, for pointers on direction. looks like another is in order :)
many thanks.
(you get a head nod too gubes, just cos you're so special :-* )
-
I appreciate it.
Actually I do have horrible admission to make. I really, really like maths and always have.
-
;D :booty:
I used to like maths a bit, when I could remember some. Never trig though.
-
You know I am a smilie illiterate and now you are confusing me with ones that move!