x atan2 y
Operand types
Type of returned value
Description
Returns the arctangens of x/y.
Returned value is in degrees, in the range -180 to +180, using the signs of both parameters to determine the quadrant of the return value.
Used In
OFP/ArmA
Example
_angle = 5 atan2 3 ..........Result is 59.0362
- Select Game -
List All
Arma3 Only
Arma2:OA Only
Arma2 Only
ArmA Only
Elite
Original OFP
- Select Group -
objects
units
groups
vehicles
weapons
arrays
items
backpacks
buldozer
mines
uniforms
vests
tasks
locations
artillery
configs
UAVs
briefings
mission flow
sites
map
draw
leaderboards
markers
environment
game
dialogs
displays
namespaces
radio
channels
FSM
diagnostics
firing from vehicles
slingload
advanced flight model
DLC
weapon stabilization
suppression
waypoints
cutscenes
sound
mathematics
variables
script commands
multiplayer
Zeus
3D editor
3D draw
doWatch is normally sufficient, but the AI often take their time to notice the object and shuffle around until they get a 'lock'. You can use setDir to instantly point them in the right direction, and atan2 helps to work out the angle:
_targetx = getPos targetObject select 0
_targety = getPos targetObject select 1
_watcherx = getPos watcherLoon select 0
_watchery = getPos watcherLoon select 1
_dir = (_targetx - _watcherx) atan2 (_targety - _watchery)
watcherLoon setDir _dir
watcherLoon doWatch targetObject
The loon will instantly turn to face the target object and the doWatch command ensures the AI continues to watch the target.