Line-of-sight behavior script interface

The ILOSBehaviorInstance interface derives from IBehaviorInstance to add APIs specific to the Line-of-sight behavior.

An additional ILOSBehaviorRay interface is returned by the castRay() method.

Line-of-sight behavior APIs

range
Set or get the maximum distance in pixels that line-of-sight can reach. If an object is further away than this distance, the object will never have line-of-sight to it, even if the intervening space is clear.
coneOfView
Set or get the angle in radians of the cone of view in which the object can have line-of-sight to other objects, relative to the current angle of the object.
hasLOStoPosition(x, y)
Returns a boolean indicating if the object currently has line-of-sight to a position in layout co-ordinates, respecting the range and cone of view.
hasLOSBetweenPositions(fromX, fromY, fromAngle, toX, toY)
Returns a boolean indicating if there is line-of-sight between any two positions in the layout, instead of using the object's own position. This respects the range and cone of view, based on fromAngle, which is in radians.
castRay(fromX, fromY, toX, toY, useCollisionCells = true)
Check for obstacle intersection between any two positions in the layout, returning a ILOSBehaviorRay interface representing the result. Check the didCollide property of the returned interface to identify if an intersection was found. The other properties of the interface indicate the hit position, normal and reflection angle, if an intersection was found. For more information see the documentation of the ILOSBehaviorRay interface below. The useCollisionCells parameter specifies whether to use the collision cells optimisation when testing line of sight. Usually this is faster, but in some cases over extremely long distances it can be slower.
ray
Returns the ILOSBehaviorRay interface representing the result of the last castRay method call.

ILOSBehaviorRay interface

This interface is used to represent the result of a call to castRay(). All its properties are read-only.

didCollide
Read-only boolean indicating whether an intersection was found.
hitX
hitY
If didCollide is true, the read-only position of the first obstacle the ray intersected, in layout co-ordinates.
hitDistance
If didCollide is true, the read-only distance between the ray start point and the hit position.
hitUid
If didCollide is true, the read-only UID of the instance that was the first obstacle the ray intersected.
getNormalX(length)
getNormalY(length)
If didCollide is true, returns a position at a given distance along the surface normal vector.
normalAngle
If didCollide is true, the read-only angle of the surface normal at the point of intersection, in radians.
getReflectionX(length)
getReflectionY(length)
If didCollide is true, returns a position at a given distance along the reflection vector.
reflectionAngle
If didCollide is true, the read-only angle of the reflection at the point of intersection, in radians.
Construct 3 Manual 2021-06-09