Detects MUs and GameObjects using collider or raycast methods with PLC signal integration for industrial automation. More...

Public Member Functions | |
delegate void | OnEnterDelegate (GameObject obj) |
Delegate function for GameObjects entering the Sensor. | |
delegate void | OnExitDelegate (GameObject obj) |
Delegate function for GameObjects leaving the Sensor. | |
void | SetNetworkControlled () |
Sets the sensor to be controlled by network synchronization. | |
void | SetOccupied (bool value) |
Manually sets the occupied state of the sensor. | |
void | DeleteMUs () |
Delete all MUs in Sensor Area. | |
void | OnMUPartsDestroyed (GameObject obj) |
void | OnMUDelete (MU muobj) |
![]() | |
void | PreStartSim () |
Is called by the realvirtualController before the component is started. | |
void | StartSim () |
Is called by the realvirtualController to start or stop the component. | |
void | StopSim () |
Vector3 | DirectionToVector (DIRECTION direction) |
Transfers the direction enumeration to a vector. | |
DIRECTION | VectorToDirection (bool torotatoin, Vector3 vector) |
Transfers a vector to the direction enumeration. | |
float | GetLocalScale (Transform thetransform, DIRECTION direction) |
List< BehaviorInterfaceConnection > | UpdateConnectionInfo () |
List< Signal > | GetConnectedSignals () |
void | SetVisibility (bool visibility) |
Sets the visibility of this object including all subobjects. | |
List< BehaviorInterfaceConnection > | GetConnections () |
List< Signal > | GetSignals () |
GameObject | GetChildByName (string name) |
Gets a child by name. | |
List< GameObject > | GetChildsByName (string name) |
Gets all child by name. | |
GameObject | GetChildByNameAlsoHidden (string name) |
List< GameObject > | GetAllMeshesWithGroup (string group) |
List< GameObject > | GetAllWithGroup (string group) |
List< GameObject > | GetAllWithGroups (List< string > groups) |
List< GameObject > | GetAllMeshesWithGroups (List< string > groups) |
List< string > | GetMyGroups () |
List< GameObject > | GetMeshesWithSameGroups () |
List< GameObject > | GetAllWithSameGroups () |
MeshRenderer | GetMeshRenderer () |
Gets the mesh renderers in the childrens. | |
void | SetCollider (bool enabled) |
sets the collider in all child objects | |
void | ErrorMessage (string message) |
Displays an error message. | |
void | ChangeConnectionMode (bool isconnected) |
void | Log (string message) |
Logs a message. | |
void | Log (string message, object obj) |
Logs a message with a relation to an object. | |
void | Warning (string message, object obj) |
Logs a warinng with a relation to an object. | |
void | Error (string message, object obj) |
Logs an error with a relation to an object. | |
void | Error (string message) |
Logs an error. | |
GameObject | DebugPosition (string debugname, Vector3 position, Quaternion quaternation, float scale) |
Displays a gizmo for debugging positions. | |
void | SetFreezePosition (bool enabled) |
Freezes all child components to the current poosition. | |
void | SetRbConstraints (RigidbodyConstraints constraints) |
virtual void | AwakeAlsoDeactivated () |
![]() | |
List< BehaviorInterfaceConnection > | GetConnections () |
List< Signal > | GetSignals () |
Public Attributes | |
bool | DisplayStatus |
string | LimitSensorToTag |
Limits the function of the sensor to a certain MU tag - also MU names are working. | |
bool | UseRaycast |
Vector3 | RayCastDirection |
float | RayCastLength |
Raycast length in millimeters. | |
float | RayCastDisplayWidth |
Raycast display line width in Unity units. | |
List< string > | AdditionalRayCastLayers |
bool | ShowSensorLinerenderer |
Material | MaterialOccupied |
Material for displaying the occupied status. | |
Material | MaterialNotOccupied |
Material for displaying the not occupied status. | |
bool | PauseOnSensor |
Pause simulation if sensor is getting high - can be used for debuging. | |
PLCInputBool | SensorOccupied |
Boolean PLC input for the Sensor signal - is true if the Sensor is occuied.. | |
PLCInputBool | SensorNotOccupied |
Boolen PLC input for the Sensor - is true if the Sensor is NOT occuied. | |
Game4AutomationEventMUSensor | EventMUSensor |
Unity event which is called for MU enter and exit. On enter it passes MU and true. On exit it passes MU and false. | |
Game4AutomationEventGameobjectSensor | EventNonMUGameObjectSensor |
Unity event which is called for non MU objects enter and exit. On enter it passes gameobject (on which the collider was detected) and true. On exit it passes gameobject and false. | |
bool | Occupied |
True if sensor is occupied. | |
GameObject | LastTriggeredBy |
Last MU which has triggered the sensor. | |
float | RayCastDistance |
Last RayCast Distance in millimeters if Raycast is used. | |
int | LastTriggeredID |
Last MUID which has triggered the sensor. | |
int | LastTriggeredGlobalID |
Last GloabalID which has triggerd the sensor. | |
int | Counter |
int | ColliderCounter |
List< MU > | CollidingMus |
List< GameObject > | CollidingObjects |
![]() | |
string | Name |
The name of the component if it should be different from the GameObject name. | |
ActiveOnly | Active |
GameObject | FromTemplate |
realvirtualController | realvirtualController |
bool | HideNonG44Components |
bool | SceneIsAdditive |
bool | ForceStop |
Events | |
OnEnterDelegate | EventEnter |
Event triggered when a GameObject enters the sensor. | |
OnExitDelegate | EventExit |
Event triggered when a GameObject exits the sensor. | |
Additional Inherited Members | |
![]() | |
enum | ActiveOnly { Always , Connected , Disconnected , Never , DontChange } |
![]() | |
static bool | DirectionIsLinear (DIRECTION direction) |
Gets back if the direction is linear or a rotation. | |
![]() | |
bool | hidename () |
bool | hideactiveonly () |
virtual void | OnStopSim () |
virtual void | OnPreStartSim () |
virtual void | OnStartSim () |
MU | GetTopOfMu (GameObject obj) |
Gets the top of an MU component (the first MU script going up in the hierarchy) | |
void | InitGame4Automation () |
Initialiates the components and gets the reference to the realvirtualController in the scene. | |
virtual void | AfterAwake () |
void | Awake () |
![]() | |
GameObject | gameObject [get] |
Detailed Description
Detects MUs and GameObjects using collider or raycast methods with PLC signal integration for industrial automation.
The Sensor is a fundamental component in realvirtual for implementing detection and presence sensing in automation systems. It simulates various types of industrial sensors including proximity sensors, photoelectric sensors, and vision sensors. The sensor can detect MUs entering or leaving its detection area and communicate this information to control systems.
Key Features:
- Two detection modes: Collider-based (volume detection) or Raycast-based (beam detection)
- Configurable detection filtering by MU tags or names for selective sensing
- Visual feedback through material changes showing occupied/not occupied states
- PLC signal integration with both normally open (SensorOccupied) and normally closed (SensorNotOccupied) outputs
- Unity Events for custom scripting integration (EventEnter and EventExit)
- Support for detecting both MUs and standard GameObjects
- Real-time visualization of sensor state in Unity Editor and runtime
- Debugging features including pause-on-detection and status display
Detection Modes:
- Collider Mode: Uses Unity trigger colliders for volumetric detection areas
- Raycast Mode: Simulates beam-type sensors with configurable direction and length
Common Applications:
- Conveyor belt position detection
- Part presence verification at workstations
- Safety light curtains and barriers
- End position detection for drives and cylinders
- Counting and tracking of products
- Collision avoidance for AGVs and robots
- Quality control and inspection stations
The Sensor component integrates with:
- PLC systems through PLCInputBool signals
- Drive components for limit switch functionality
- Transport surfaces for product tracking
- Grip and Fixer components for part detection
- Custom control logic through Unity Events
Performance Considerations:
- Use layer filtering to optimize raycast performance
- Consider using tag filtering to reduce unnecessary detections
- Disable visual feedback (DisplayStatus) in production builds for better performance
For detailed documentation see: https://doc.realvirtual.io/components-and-scripts/sensor
Member Function Documentation
◆ DeleteMUs()
void realvirtual.Sensor.DeleteMUs | ( | ) |
Delete all MUs in Sensor Area.
◆ OnEnterDelegate()
delegate void realvirtual.Sensor.OnEnterDelegate | ( | GameObject | obj | ) |
Delegate function for GameObjects entering the Sensor.
◆ OnExitDelegate()
delegate void realvirtual.Sensor.OnExitDelegate | ( | GameObject | obj | ) |
Delegate function for GameObjects leaving the Sensor.
◆ SetNetworkControlled()
void realvirtual.Sensor.SetNetworkControlled | ( | ) |
Sets the sensor to be controlled by network synchronization.
◆ SetOccupied()
void realvirtual.Sensor.SetOccupied | ( | bool | value | ) |
Manually sets the occupied state of the sensor.
Member Data Documentation
◆ EventMUSensor
Game4AutomationEventMUSensor realvirtual.Sensor.EventMUSensor |
Unity event which is called for MU enter and exit. On enter it passes MU and true. On exit it passes MU and false.
◆ EventNonMUGameObjectSensor
Game4AutomationEventGameobjectSensor realvirtual.Sensor.EventNonMUGameObjectSensor |
Unity event which is called for non MU objects enter and exit. On enter it passes gameobject (on which the collider was detected) and true. On exit it passes gameobject and false.
◆ LastTriggeredBy
GameObject realvirtual.Sensor.LastTriggeredBy |
Last MU which has triggered the sensor.
◆ LastTriggeredGlobalID
int realvirtual.Sensor.LastTriggeredGlobalID |
Last GloabalID which has triggerd the sensor.
◆ LastTriggeredID
int realvirtual.Sensor.LastTriggeredID |
Last MUID which has triggered the sensor.
◆ LimitSensorToTag
string realvirtual.Sensor.LimitSensorToTag |
Limits the function of the sensor to a certain MU tag - also MU names are working.
◆ MaterialNotOccupied
Material realvirtual.Sensor.MaterialNotOccupied |
Material for displaying the not occupied status.
◆ MaterialOccupied
Material realvirtual.Sensor.MaterialOccupied |
Material for displaying the occupied status.
◆ Occupied
bool realvirtual.Sensor.Occupied |
True if sensor is occupied.
◆ PauseOnSensor
bool realvirtual.Sensor.PauseOnSensor |
Pause simulation if sensor is getting high - can be used for debuging.
◆ RayCastDisplayWidth
float realvirtual.Sensor.RayCastDisplayWidth |
Raycast display line width in Unity units.
◆ RayCastDistance
float realvirtual.Sensor.RayCastDistance |
Last RayCast Distance in millimeters if Raycast is used.
◆ RayCastLength
float realvirtual.Sensor.RayCastLength |
Raycast length in millimeters.
◆ SensorNotOccupied
PLCInputBool realvirtual.Sensor.SensorNotOccupied |
Boolen PLC input for the Sensor - is true if the Sensor is NOT occuied.
◆ SensorOccupied
PLCInputBool realvirtual.Sensor.SensorOccupied |
Boolean PLC input for the Sensor signal - is true if the Sensor is occuied..
Event Documentation
◆ EventEnter
OnEnterDelegate realvirtual.Sensor.EventEnter |
Event triggered when a GameObject enters the sensor.
◆ EventExit
OnExitDelegate realvirtual.Sensor.EventExit |
Event triggered when a GameObject exits the sensor.