Home   Help Search Login Register  

Author Topic: Examples of atan2 needed  (Read 579 times)

0 Members and 1 Guest are viewing this topic.

captain caffeine

  • Guest
Examples of atan2 needed
« on: 11 Dec 2002, 04:00:45 »
  What I need is just as it states , I understand that the command takes the x z coords and converts them into radians
or degrees or whatever, but heres what I want to do
a unit calls for help or a fire mission or what have you upon the triggering of this,  UnitB (responding) to help UnitA requesting.  

  UnitB gets the direction of UnitA using the atan2 command and faces the direction of the unit calling for help or at least the gunner will aim weapon in that direction.

 So what I need is an example or several  of the atan2 command making this unit face the direction of requesting unit.  any help will be greatly appreciated.

Offline toadlife

  • OFPEC Old Skool
  • Former Staff
  • ****
  • Official OFP Editing Center Toad
    • toadlife.net
Re:Examples of atan2 needed
« Reply #1 on: 11 Dec 2002, 04:29:45 »
I used it to get the compass heading from one object to another.....here ya go!

Code: [Select]
; ##the object ebing tracked
_trackee = w6

; ##the object tracking the object being tracked
_tracker = leader gw1

#start
_tracker = leader gw1

; ##the compass heading from the tracker to the trackee is calculated here

_dir = getdir (vehicle _tracker)
_degree = ((getpos _trackee select 0) - (getpos _tracker select 0)) atan2 ((getpos _trackee select 1) - (getpos _tracker select 1))

; ## "_degree" is the compass heading the tracker needs to point to face the trackee
?_degree < 0:_degree = _degree + 360
"Whenever you want information on the 'net, don't ask a question; just post a wrong answer." -- Cancer Omega.

captain caffeine

  • Guest
Re:Examples of atan2 needed
« Reply #2 on: 11 Dec 2002, 05:10:42 »
OK cool , now heres a stupid question, is this a short script
and if so how would one implement its use, I would assume
give it a name like     setDir.sqs  and in itit line of trigger or if conditions are met [trackee , tracker] init setDir.sqs?