Distance Sensor
The distance sensor component detects the presence of an entity and measures the distance from the sensor to the detected entity. For more details on all the properties associated with the distance sensor component and how to use the distance sensor component with scripting, please see the API documentation.
The detected entity is the nearest entity to the origin of the detection beam. This is implemented by performing a physics raycast.
Properties
The distance sensor component properties that are accessible through the inspector.
Origin
The start of the detection beam. You can click the feature selection button to select a feature from the mesh. Hover over the feature you want to select and then left-click to confirm the selection.
Direction
The direction of the detection beam. You can click the feature selection button to select a feature from the mesh. Hover over the feature you want to select then left-click to confirm the selection. You can right click whilst hovering to negate the direction vector.
Range
The maximum range of the distance sensor.
Layer
The collision layer for detecting entities. Entities with layers that are set to collide with this layer will be detected by the distance sensor. Otherwise, the entity will not be detected by the distance sensor. If no layer is specified, then every entity that intersects the detection geometry is detected by the distance sensor.
Kinematics
Whether entities with kinematic rigid bodies should be detected.
Distance
The measured distance to the detected entity, or 0 if no entity is detected.
Object
The detected entity, or null if no entity is detected.
Blocked
The graphics material used when the distance sensor is blocked, or null to keep using the material specified by the graphics component.
Cleared
The graphics material used when the distance sensor is cleared, or null to keep using the material specified by the graphics component.
IO
The IO signals for the distance sensor component. Please see the DistanceSensorIO API documentation for more details.
Distance
A double readable (output) signal that stores the measured distance. The value will be 0 if the distance sensor does not detect an entity.
State
A boolean readable (output) signal that has the value true if the distance sensor detects an entity, and false if the distance sensor does not detect an entity.