Source component that generates MUs (Movable Units) during simulation runtime, simulating production systems and material supply points. More...

Public Member Functions | |
void | DeleteAll () |
Deletes all MU generated by this Source. | |
void | OnMUDelete (MU mu) |
Is Celled when MU is deleted which has been created by this source. | |
void | DeleteAllImmediate () |
Deletes all MU generated by this Source. | |
void | OnXRInit (GameObject placedobj) |
Event called on Init in XR Space. | |
void | OnXRStartPlace (GameObject placedobj) |
Event when XR is Starting placing. | |
void | OnXREndPlace (GameObject placedobj) |
Event when XR is Ending placing. | |
MU | Generate () |
Generates an MU. | |
![]() | |
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 | UseAGXPhysics |
GameObject | ThisObjectAsMU |
The referenced GameObject which should be used as a prototype for the MU. If it is null it will be this GameObject. | |
GameObject | Destination |
The destination GameObject where the generated MU should be placed. | |
bool | Enabled |
If set to true the Source is enabled. | |
bool | FreezeSourcePosition |
If set to true the Source itself (the MU template) is fixed to its position. | |
bool | DontVisualize |
True if the Source should not be visible during Simulation time. | |
bool | HideOnStop |
Hide this source when simulation is stopped / paused;. | |
float | Mass |
Mass of the generated MU in kilograms. | |
bool | SetCenterOfMass |
Vector3 | CenterOfMass |
Center of mass position for the generated MU in local coordinates. | |
string | GenerateOnLayer |
Layer where the MUs should be generated to - if kept empty no layers are changed. | |
bool | ChangeDefaultLayer |
If set to true Layers are automatically changed if default Layer is detected. | |
List< string > | OnCreateDestroyComponents |
Destroy these components on MU when MU is created as a copy of the source - is used to delete additional source scripts. | |
float | StartInterval |
Start MU creation with the given seconds after simulation start. | |
float | Interval |
Interval in seconds between the generation of MUs. Needs to be set to 0 if no interval generation is wished. | |
bool | AutomaticGeneration |
Automatic generation of MUs if last MU is above the GenerateIfDistance distance from MU. | |
float | GenerateIfDistance |
Distance in millimeters from Source when new MUs should be generated. | |
bool | RandomDistance |
If turned on Distance is Random Number with plus / minus Range Distance. | |
float | RangeDistance |
Range of the distance in millimeters (plus / minus) if RandomDistance is turned on. | |
bool | LimitNumber |
int | MaxNumberMUs |
int | Created |
bool | GenerateMU |
When changing from false to true a new MU is generated. | |
bool | DeleteAllMU |
When changing from false to true all MUs generated by this Source are deleted. | |
PLCOutputBool | SourceGenerate |
When changing from false to true a new MU is generated. | |
PLCOutputBool | SourceGenerateOnDistance |
When true MUs are generated on Distance. | |
realvirtualEventMUCreated | EventMUCreated |
Event triggered when a new MU is created. | |
bool | PositionOverwrite |
![]() | |
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 |
Protected Member Functions | |
void | Reset () |
void | Start () |
override void | OnStartSim () |
For Layout Editor mode Start is called when the simulation is started. | |
override void | OnStopSim () |
For Layout Editor mode Stop is called when the simulation is stopped. | |
![]() | |
bool | hidename () |
bool | hideactiveonly () |
virtual void | OnPreStartSim () |
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 () |
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. | |
![]() | |
GameObject | gameObject [get] |
Detailed Description
Source component that generates MUs (Movable Units) during simulation runtime, simulating production systems and material supply points.
The Source is a fundamental component in realvirtual for creating MUs (products, parts, materials) that flow through the automation system. It acts as the starting point of material flow, simulating everything from raw material feeders to production output points. Sources can generate MUs based on time intervals, distances, PLC signals, or manual triggers.
Key Features:
- Template-based MU generation using any GameObject as a prototype
- Multiple generation modes: interval-based, distance-based, signal-based, or manual
- Automatic generation when previous MU reaches a specified distance
- PLC signal integration for controlled generation (PLCGenerate signal)
- Configurable physics properties including mass and center of mass
- Support for random variations in generation timing and positioning
- Batch generation capabilities for creating multiple MUs simultaneously
- Layer management for proper collision detection setup
- Component cleanup to remove unnecessary scripts from generated MUs
Generation Modes:
- Interval Generation: Creates MUs at fixed time intervals
- Distance-Based: Generates new MU when last one reaches specified distance
- PLC Controlled: Generation triggered by PLC signals
- Manual: Direct creation through Generate() method calls
- Batch Mode: Creates multiple MUs at once with configurable spacing
Common Applications:
- Raw material feeders in production lines
- Product generation at machine outputs
- Box/container suppliers for packaging systems
- Pallet dispensers in warehouse automation
- Part feeders for assembly stations
- Test object generation for simulation scenarios
- Order-based production simulation
- Buffer replenishment systems
Advanced Features:
- Random distance variations for realistic material flow
- Maximum MU limits to prevent overflow
- Automatic ID assignment for tracking and traceability
- Support for multiple visual appearances (with PartChanger)
- Configurable spawn positions and destinations
- Automatic hiding of template object during simulation
- Integration with AGX physics engine (Professional version)
PLC Integration:
- PLCGenerate: Input signal to trigger MU generation
- PLCIsGenerated: Output signal confirming MU creation
- PLCNumGenerated: Integer output with total count of generated MUs
- Signal-based control for Industry 4.0 scenarios
Performance Considerations:
- Efficient GameObject pooling for high-frequency generation
- Automatic component cleanup reduces memory overhead
- Layer-based collision optimization
- Configurable physics settings for performance tuning
Events:
- EventMUCreated: Triggered when MU is successfully created
- Provides created MU reference for custom logic integration
For detailed documentation see: https://doc.realvirtual.io/components-and-scripts/source
Member Function Documentation
◆ DeleteAll()
void realvirtual.Source.DeleteAll | ( | ) |
Deletes all MU generated by this Source.
◆ DeleteAllImmediate()
void realvirtual.Source.DeleteAllImmediate | ( | ) |
Deletes all MU generated by this Source.
◆ Generate()
MU realvirtual.Source.Generate | ( | ) |
Generates an MU.
Check if still default layer – if yes then set box collider to g4a MU
◆ OnMUDelete()
void realvirtual.Source.OnMUDelete | ( | MU | mu | ) |
Is Celled when MU is deleted which has been created by this source.
◆ OnStartSim()
|
protectedvirtual |
For Layout Editor mode Start is called when the simulation is started.
Reimplemented from realvirtual.realvirtualBehavior.
◆ OnStopSim()
|
protectedvirtual |
For Layout Editor mode Stop is called when the simulation is stopped.
Reimplemented from realvirtual.realvirtualBehavior.
◆ OnXREndPlace()
void realvirtual.Source.OnXREndPlace | ( | GameObject | placedobj | ) |
Event when XR is Ending placing.
IMPLEMENTS IXRPlaceable::OnXREndPlace
◆ OnXRInit()
void realvirtual.Source.OnXRInit | ( | GameObject | placedobj | ) |
Event called on Init in XR Space.
IMPLEMENTS IXRPlaceable::OnXRInit
◆ OnXRStartPlace()
void realvirtual.Source.OnXRStartPlace | ( | GameObject | placedobj | ) |
Event when XR is Starting placing.
IMPLEMENTS IXRPlaceable::OnXRStartPlace
Member Data Documentation
◆ AutomaticGeneration
bool realvirtual.Source.AutomaticGeneration |
Automatic generation of MUs if last MU is above the GenerateIfDistance distance from MU.
◆ CenterOfMass
Vector3 realvirtual.Source.CenterOfMass |
Center of mass position for the generated MU in local coordinates.
◆ ChangeDefaultLayer
bool realvirtual.Source.ChangeDefaultLayer |
If set to true Layers are automatically changed if default Layer is detected.
◆ DeleteAllMU
bool realvirtual.Source.DeleteAllMU |
When changing from false to true all MUs generated by this Source are deleted.
◆ Destination
GameObject realvirtual.Source.Destination |
The destination GameObject where the generated MU should be placed.
◆ DontVisualize
bool realvirtual.Source.DontVisualize |
True if the Source should not be visible during Simulation time.
◆ Enabled
bool realvirtual.Source.Enabled |
If set to true the Source is enabled.
◆ EventMUCreated
realvirtualEventMUCreated realvirtual.Source.EventMUCreated |
Event triggered when a new MU is created.
◆ FreezeSourcePosition
bool realvirtual.Source.FreezeSourcePosition |
If set to true the Source itself (the MU template) is fixed to its position.
◆ GenerateIfDistance
float realvirtual.Source.GenerateIfDistance |
Distance in millimeters from Source when new MUs should be generated.
◆ GenerateMU
bool realvirtual.Source.GenerateMU |
When changing from false to true a new MU is generated.
◆ GenerateOnLayer
string realvirtual.Source.GenerateOnLayer |
Layer where the MUs should be generated to - if kept empty no layers are changed.
◆ HideOnStop
bool realvirtual.Source.HideOnStop |
Hide this source when simulation is stopped / paused;.
◆ Interval
float realvirtual.Source.Interval |
Interval in seconds between the generation of MUs. Needs to be set to 0 if no interval generation is wished.
◆ Mass
float realvirtual.Source.Mass |
Mass of the generated MU in kilograms.
◆ OnCreateDestroyComponents
List<string> realvirtual.Source.OnCreateDestroyComponents |
Destroy these components on MU when MU is created as a copy of the source - is used to delete additional source scripts.
◆ RandomDistance
bool realvirtual.Source.RandomDistance |
If turned on Distance is Random Number with plus / minus Range Distance.
◆ RangeDistance
float realvirtual.Source.RangeDistance |
Range of the distance in millimeters (plus / minus) if RandomDistance is turned on.
◆ SourceGenerate
PLCOutputBool realvirtual.Source.SourceGenerate |
When changing from false to true a new MU is generated.
◆ SourceGenerateOnDistance
PLCOutputBool realvirtual.Source.SourceGenerateOnDistance |
When true MUs are generated on Distance.
◆ StartInterval
float realvirtual.Source.StartInterval |
Start MU creation with the given seconds after simulation start.
◆ ThisObjectAsMU
GameObject realvirtual.Source.ThisObjectAsMU |
The referenced GameObject which should be used as a prototype for the MU. If it is null it will be this GameObject.