OFPEC Forum

Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: CopyrightPhilly on 25 Jun 2005, 18:59:37

Title: bearing from player to object
Post by: CopyrightPhilly on 25 Jun 2005, 18:59:37
can anyone tell me how to work out the bearing from the player to an object?

cheers,
Phil
Title: Re:bearing from player to object
Post by: h- on 25 Jun 2005, 19:20:34
http://www.ofpec.com/editors/funcref.php?filter_func=16

use that function like this:
[position player,position object] call DirToPos

Should do the trick..
Title: Re:bearing from player to object
Post by: CopyrightPhilly on 25 Jun 2005, 19:35:02
thanks HateR_Kint

I wanted this function to work in 1.46 so i had to make it into an sqs file and then execute it...

this is what i ended up with

Code: [Select]
_unit = _this select 0
_object = _this select 1

_posA = getpos _unit
_posB = getpos _object

_dir = ((_posB select 0) - (_posA select 0)) atan2 ((_posB select 1) - (_posA select 1))

?_dir < 0: _dir = _dir + 360

_dir = ((_dir + 0.5) - ((_dir + 0.5) % 1))

hint format ["%1",_dir]

exit

this will display the bearing as a whole number