Line-of-sight behavior script interface
ILOSBehaviorInstance interface derives from IBehaviorInstance to add APIs specific to the Line-of-sight behavior.
ILOSBehaviorRay interface is returned by the
Line-of-sight behavior APIs
- 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.
- 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.
- Returns the
ILOSBehaviorRay interface representing the result of the last
castRay method call.
This interface is used to represent the result of a call to
castRay(). All its properties are read-only.
- Read-only boolean indicating whether an intersection was found.
- If didCollide is true, the read-only position of the first obstacle the ray intersected, in layout co-ordinates.
- If didCollide is true, the read-only distance between the ray start point and the hit position.
- If didCollide is true, the read-only UID of the instance that was the first obstacle the ray intersected.
- If didCollide is true, returns a position at a given distance along the surface normal vector.
- If didCollide is true, the read-only angle of the surface normal at the point of intersection, in radians.
- If didCollide is true, returns a position at a given distance along the reflection vector.
- If didCollide is true, the read-only angle of the reflection at the point of intersection, in radians.
Construct 3 Manual
You are here:
Search this manual:
This manual entry was last updated on 9 Jun, 2021 at 19:26