Sensors
Contains functions for detecting Entity or Player.
This module can only be used in Entity scripts.
Functions
setDefaultDetectionRadius(radius)
Sets default radius and length values. It is used for onObjectEnter callbacks and serves as a fallback when radius or length is not passed.
Parameters
- radius — Default radius or length.
setDefaultViewAngle(angle)
Sets default viewing angle. It is used for onObjectEnter callbacks and serves as a fallback when radius or length is not passed.
Parameters
- angle — Range of detection from the target's front. 0-360 degrees.
getPlayerDisplacement(radius, client)
Returns displacement of Player. If no player specified, the closest one will be used.
Parameters
- radius — Radius of check (optional).
- client — Player to look for (optional).
Returns
Displacement vector. Empty vector if no players found.
getEntityDisplacement(radius, entity)
Returns displacement of Entity. If no entity specified, the closest one will be used.
Parameters
- radius — Radius of check (optional).
- entity — Entity to look for (optional).
Returns
Displacement vector. Empty vector if no entities found.
getEntityCategoryDisplacement(radius, categoryType)
Returns displacement of entity of specified CategoryType.
Parameters
- radius — Radius of check (optional).
- categoryType — CategoryType to look for.
Returns
Displacement vector. Empty vector if no entities found.
setSensorType(sensorType)
Sets the type of sensor the the entity will use to detect objects.
Parameters
- sensorType — SensorType.
setSensorOffset(offset)
Sets the position of the sensor relative to the entity.
Parameters
- offset — Vector3 offset in local space.
setSensorSize(size)
Sets the volume or range the entity will detect objects from.
Parameters
- size — Number or Vector3for the size of the sensor (in voxels).
setProximitySensorAngle(angle)
Sets the angle this entity will detect objects from. A lower angle means this entity needs to be facing an object more directly to detect it.
Parameters
- angle — Angle value in degrees.
Radar Functions
radar.detectsPlayer(radius, client)
Checks if radar sensor detects player.
Parameters
- radius — Radius of check (optional).
- client — Player to look for (optional).
Returns
True if player was detected.
radar.detectsEntity(radius, entity)
Checks if radar sensor detects entity.
Parameters
- radius — Radius of check (optional).
- entity — Entity to look for (optional).
Returns
True if entity was detected.
radar.detectsEntityCategory(radius, categoryType)
Checks if radar sensor detects entity of specified CategoryType.
Parameters
- radius — Radius of check (optional).
- categoryType — CategoryType to look for.
Returns
True if entity was detected.
radar.detect(radius, entityFilter, playerFilter)
Returns all Entity and Player objects detected in the specified radius.
Parameters
- radius — Radius of the detection range.
- entityFilter — True/false or array of Entity Codes to detect. (optional, default: true).
- playerFilter — True/false or array of Player client IDs to detect. (optional, default: true).
Returns
Array of Entity and Player objects detected.
Side Functions
side.detectsPlayer(side, client)
Checks if the player is nearby.
Parameters
Returns
True if player was detected.
side.detectsEntity(side, entity)
Checks if the entity is nearby.
Parameters
Returns
True if entity was detected.
side.detectsEntityCategory(side, categoryType)
Checks if the player is nearby.
Parameters
Returns
True if entity was detected.
Laser Functions
laser.detectsPlayer(side, length, client)
Casts laser in direction of Bearing to detect Player.
Parameters
- side — Bearing of the detection.
- length — Laser length (optional).
- client — Player to look for (optional).
Returns
True if player was detected.
laser.detectsEntity(side, length, entity)
Casts laser in direction of Bearing to detect Entity.
Parameters
- side — Bearing of the detection.
- length — Laser length (optional).
- entity — Entity to look for (optional).
Returns
True if entity was detected.
laser.detectsEntityCategory(side, length, categoryType)
Casts laser in direction of Bearing to detect entity of CategoryType.
Parameters
- side — Bearing of the detection.
- length — Laser length (optional).
- categoryType — CategoryType to look for.
Returns
True if entity was detected.
laser.detect(side, length, entityFilter, playerFilter)
Casts laser in direction of Bearing to detect Entity and Player objects.
Parameters
- side — Bearing of the detection.
- length — Laser length (optional).
- entityFilter — True/false or array of Entity Codes to detect. (optional, default: true).
- playerFilter — True/false or array of Player client IDs to detect. (optional, default: true).
Returns
Array of Entity and Player objects detected.
Sight Functions
sight.detectsPlayer(angle, length, client)
Detects Player and checks if it is within a vision cone.
Parameters
- angle — Vision cone angle.
- length — Maximum length (optional).
- client — Player to look for (optional).
Returns
True if player was detected.
sight.detectsEntity(angle, length, entity)
Casts laser in direction of Bearing to detect Entity.
Parameters
- angle — Vision cone angle.
- length — Maximum length (optional).
- entity — Entity to look for (optional).
Returns
True if entity was detected.
sight.detectsEntityCategory(angle, length, categoryType)
Casts laser in direction of Bearing to detect entity of CategoryType.
Parameters
- angle — Vision cone angle.
- length — Maximum length (optional).
- categoryType — CategoryType to look for.
Returns
True if entity was detected.