Home   Help Search Login Register  

Author Topic: bearing from player to object  (Read 736 times)

0 Members and 1 Guest are viewing this topic.

CopyrightPhilly

  • Guest
bearing from player to object
« 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

Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Re:bearing from player to object
« Reply #1 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..
Project MCAR   ---   Northern Fronts   ---   Emitter 3Ditor
INFORMATIVE THREAD TITLES PLEASE. "PLEASE HELP" IS NOT ONE..
Chuck Norris can divide by zero.

CopyrightPhilly

  • Guest
Re:bearing from player to object
« Reply #2 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