A ProximitySensor is a component that can detect objects in a specified detection field. At least one trigger collider needs to be assigned to function as the detection field for the ProximitySensor.
A Trigger Collider does not have to be on the same GameObject as the ProximitySensor
The Proximity Sensor can be found under Standard Components >Proximity Sensor > Add Physical component.
This will add the Proximity Sensor component to the currently selected object or create a new empty GameObject with the component attached if no objects are selected.
The following inspector component will be shown:
The images below show the complete feature layout of the Proximity Sensor component.
Shows whether the sensor is currently active
Low when no object is detected. High when at least one object is detected.
Detected Objects (n)
The number of objects detected within all the Triggers
On Signal High()
Actions executed when Output Signal is set to high
On Signal Low()
Actions executed when Output Signal is set to low
The detection field for the Proximity Sensor
When checked creates Rigidbodies on the trigger objects when you enter play mode.
Generate Control Panel for SlideSwitch
Creates a Control Panel for the Proximity Sensor
Create the Colliders to be used as the detection space for the Proximity Sensor and set them to be triggers
2. Add the trigger colliders as Triggers
3. Add an action to the Proximity Sensor
4. Test if the actions are activated in runtime