To tell if object 1 is facing object 2 (as an example) I would use the following steps:
(1) Get the distances between the two objects.
xdist# = object position x(2) - object position x(1)
zdist# = object position z(2) - object position z(1)
(2) Get the angle between the two objects.
targetang# = atanfull(xdist#,zdist#)
(3) Check if the angle is similar to the angle of the first object.
tolerance# = 15.0
change# = wrapvalue(object angle y(1) - targetang#)
if (change# < tolerance#) or (change# > (360.0 - tolerance#))
facing = 1
else
facing = 0
endif
This code only takes the y angle into account but can be easily adapted for other angles aswell.
Hope it's helpful
Also, here it is as a function, it will return a 1 if object a is facing object b with a certain degree of tolerance:
function ObjectFacing(a,b,tolerance#)
xdist# = object position x(b) - object position x(a)
zdist# = object position z(b) - object position z(a)
targetang# = atanfull(xdist#,zdist#)
change# = wrapvalue(object angle y(a) - targetang#)
if (change# < tolerance#) or (change# > (360.0 - tolerance#))
facing = 1
else
facing = 0
endif
endfunction facing
Hope it helps