Skip to content

ProximitySensor ​

class in OpalScript

Detects nearby objects in a radius or facing cone, with optional group, component and line-of-sight filters. Does not move or attack.

Properties ​

MemberDescription
ProximitySensor.NearestIdRead-only runtime value. Use component methods to change state.
ProximitySensor.CountRead-only runtime value. Use component methods to change state.
ProximitySensor.EnabledWhether this component is enabled. Use SetEnabled to change it.

Methods ​

MemberDescription
ProximitySensor.SetEnabledEnables sensing, or disables it and clears detected IDs and count immediately.
ProximitySensor.HasTargetsReturns true when the latest scan detected at least one object.

Events ​

MemberDescription
ProximitySensor.enteredEmits an object's ID when it first satisfies this sensor's range and filters.
ProximitySensor.exitedEmits an object's ID when it leaves the range or no longer satisfies the filters.
ProximitySensor.nearestChangedEmits the previous and current nearest object IDs; an empty ID means no detected object.

See also ​