Controls linear and rotational motion of GameObjects with precise position, speed, and acceleration control for industrial automation. More...

Public Member Functions | |
delegate void | DelegateDriveStartInit (Drive drive) |
value for overwriting speed (transportsurfaces) for replaying recordings or multiplayer | |
delegate void | OnAtPositionEvent (Drive drive) |
Delegate function for the Drive reaching the destination position. | |
delegate void | OnJumpToLowerLimitEvent (Drive drive) |
Delegate function for when drive jumps to lower limit. | |
List< TransportSurface > | GetTransportSurfaces () |
void | AddSubDrive (Drive drive) |
void | OnXRInit (GameObject placedobj) |
Initializes the drive for XR/AR placement operations. | |
void | OnXRStartPlace (GameObject placedobj) |
Stops the drive when XR/AR placement begins to prevent movement during positioning. | |
void | OnXREndPlace (GameObject placedobj) |
Resumes drive operation after XR/AR placement is completed. | |
void | Forward () |
Starts the drive to move forward with the target speed. | |
void | Backward () |
Starts the drive to move forward with the target speed. | |
void | DriveTo (float Target) |
Starts the drive to drive to the given Target with the target speed. | |
void | DriveTo (float Target, float time) |
Starts the drive to drive to the given Target with a custom time - acceleration (or Speed on no Acceleration) will be calculated to reach time. | |
float | GetTimeTo (float Target) |
Calculates the time to the target. | |
void | Accelerate () |
Starts the drive - it will speed up with sinoide if turned on. | |
void | Decelerate () |
void | Stop () |
Stops the drive at the current position. | |
Vector3 | GetLocalDirection () |
Gets the axis vector of the drive. | |
void | OnDestroy () |
void | StartEditorMoveMode () |
void | SetPositionEditorMoveMode (float editorposition) |
void | EndEditorMoveMode () |
Vector3 | GetStartPos () |
Gets the start position of the drive in local scale. | |
Vector3 | GetStartRot () |
Gets the start position of the drive in local scale. | |
void | SetPositionAndSpeed (float Position, float Speed) |
void | SetPosition (float Position) |
Gets the current speed of the drive and updates the visual position. | |
Vector3 | GetGlobalDirection () |
void | CalculateVectors () |
void | DriveReset () |
void | OnEditModeFinished () |
Cleans up references when Unity Editor exits edit mode. | |
![]() | |
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 () |
Public Attributes | |
DIRECTION | Direction |
The direction in local coordinate system of the GameObject where the drive is attached to. | |
bool | ReverseDirection |
Set to true if Direction needs to be inverted. | |
float | Offset |
Start offset of the drive from zero position in millimeters or degrees. | |
float | StartPosition |
Start Position off the Drive. | |
float | SpeedOverride |
Factor for locally overriding the speed and acceleration of this drive. | |
float | SpeedScaleTransportSurface |
Scale of the Speed for radial transportsurfaces to feed in mm/s on radius. | |
bool | MoveThisRigidBody |
If set to true the RigidBodies are moved (use it if moving) part has attached colliders, if false the transforms are moved. | |
bool | EditorMoveMode |
bool | UseLimits |
float | LowerLimit |
Lower Drive Limit, Upper and Lower = 0 if this should not be used. | |
float | UpperLimit |
Upper Drive Limit, Upper and Lower = 0 if this should not be used. | |
bool | JumpToLowerLimitOnUpperLimit |
Sensor | LimitRayCast |
bool | UseAcceleration |
If set to true the drive uses the acceleration. | |
bool | SmoothAcceleration |
if set to true the drive uses smooth acceleration with a sinoide function | |
float | Acceleration |
The acceleration in millimeter per second^2. | |
float | Jerk |
bool | JogForward |
A jog bit for jogging forward with the Target Speed. | |
bool | JogBackward |
A jog bit for jogging backwards with the Target Speed. | |
float | TargetPosition |
The target position of the Drive. | |
float | TargetSpeed |
The target speed in millimeter / second of the Drive. | |
bool | TargetStartMove |
When changing to true the Drive is starting to move to the TargetPosition. | |
bool | BlockDestination |
If Block Drive is true it will not drive to its Target Positon, Jogging is possible. | |
bool | ResetDrive |
Resets the Drive to the zero position and stops all movements. | |
bool | _StopDrive |
Stops the Drive at the current position. | |
float | CurrentSpeed |
The current speed of the drive. | |
float | CurrentPosition |
float | PositionOverwriteValue |
float | IsPosition |
current position, can be overwritten by DriveOverwrite or current position | |
float | IsSpeed |
current speed, can be overwritten by SpeedOverwrite or current position | |
bool | IsStopped |
Is true if Drive is stopped. | |
bool | IsRunning |
Is true if Drive is running. | |
bool | IsAtTargetSpeed |
Is true if Drive is running. | |
bool | IsAtTarget |
Is true if Drive is at target position. | |
bool | IsAtLowerLimit |
Is true if Drive is jogging and reaching lower Limit. | |
bool | IsSubDrive |
DriveEvent | OnBeforeDriveCalculation |
Unity Event before calculating drive. | |
DriveEvent | OnAfterDriveCalculation |
Unity Event after calculating drive. | |
bool | IsAtUpperLimit |
Is true if Drive is jogging and reaching upper Limit. | |
bool | HideGizmos |
float | StandardSpeed |
float | StandardAcceleration |
bool | UseInteract |
bool | IsRotation |
bool | PositionOverwrite |
true for overwriting position for replaying recordings or multiplayer | |
bool | SpeedOverwrite |
true for overwriting speed (transportsurfaces) for replaying recordings or multiplayer | |
float | SpeedOverwriteValue |
DelegateDriveStartInit | AfterDriveStartInit |
Drive[] | _subdrives |
![]() | |
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 | |
override void | OnStartSim () |
![]() | |
bool | hidename () |
bool | hideactiveonly () |
virtual void | OnStopSim () |
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 () |
Events | |
OnAtPositionEvent | OnAtPosition |
Event triggered when drive reaches the destination position. | |
OnJumpToLowerLimitEvent | OnJumpToLowerLimit |
Event triggered when drive jumps to lower limit. | |
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. | |
Detailed Description
Controls linear and rotational motion of GameObjects with precise position, speed, and acceleration control for industrial automation.
The Drive is one of the core components in realvirtual for simulating motion in automation systems. It moves components including all sub-components along the local axis of the GameObject. Both rotational and linear movements are possible. A drive can be enhanced by DriveBehaviours which add special behaviors as well as Input and Output signals for PLC integration.
Key Features:
- Precise position and speed control with configurable acceleration and deceleration
- Support for linear movements (X, Y, Z axes) and rotational movements (around X, Y, Z axes)
- Position limits with automatic limit switches and optional cyclic movement
- PLC signal integration for industrial control system connectivity
- Smooth acceleration profiles including S-curve motion for jerk-limited movement
- Speed override capabilities for runtime speed adjustments
- Visual feedback in Unity Editor with gizmos showing movement direction and limits
- Support for both transform-based and physics-based (Rigidbody) movement
Common Applications:
- Conveyor belts and transport systems
- Linear actuators and pneumatic cylinders
- Servo motors and rotational axes
- Robot joints and kinematic chains
- Lifting platforms and elevators
- Sliding doors and gates
The Drive component can be controlled through:
- Direct properties (JogForward, JogBackward, TargetPosition)
- PLC signals via DriveBehavior components
- Unity Events for position reached notifications
- Custom scripts accessing the public API
For detailed documentation see: https://doc.realvirtual.io/components-and-scripts/motion/drive
Member Function Documentation
◆ Accelerate()
void realvirtual.Drive.Accelerate | ( | ) |
Starts the drive - it will speed up with sinoide if turned on.
◆ Backward()
void realvirtual.Drive.Backward | ( | ) |
Starts the drive to move forward with the target speed.
◆ DelegateDriveStartInit()
delegate void realvirtual.Drive.DelegateDriveStartInit | ( | Drive | drive | ) |
value for overwriting speed (transportsurfaces) for replaying recordings or multiplayer
◆ DriveTo() [1/2]
void realvirtual.Drive.DriveTo | ( | float | Target | ) |
Starts the drive to drive to the given Target with the target speed.
◆ DriveTo() [2/2]
void realvirtual.Drive.DriveTo | ( | float | Target, |
float | time | ||
) |
Starts the drive to drive to the given Target with a custom time - acceleration (or Speed on no Acceleration) will be calculated to reach time.
◆ Forward()
void realvirtual.Drive.Forward | ( | ) |
Starts the drive to move forward with the target speed.
◆ GetLocalDirection()
Vector3 realvirtual.Drive.GetLocalDirection | ( | ) |
Gets the axis vector of the drive.
◆ GetStartPos()
Vector3 realvirtual.Drive.GetStartPos | ( | ) |
Gets the start position of the drive in local scale.
◆ GetStartRot()
Vector3 realvirtual.Drive.GetStartRot | ( | ) |
Gets the start position of the drive in local scale.
◆ GetTimeTo()
float realvirtual.Drive.GetTimeTo | ( | float | Target | ) |
Calculates the time to the target.
◆ OnAtPositionEvent()
delegate void realvirtual.Drive.OnAtPositionEvent | ( | Drive | drive | ) |
Delegate function for the Drive reaching the destination position.
◆ OnEditModeFinished()
void realvirtual.Drive.OnEditModeFinished | ( | ) |
Cleans up references when Unity Editor exits edit mode.
IMPLEMENTS IEditModeFinished::OnEditModeFinished
Implements realvirtual.IEditModeFinished.
◆ OnJumpToLowerLimitEvent()
delegate void realvirtual.Drive.OnJumpToLowerLimitEvent | ( | Drive | drive | ) |
Delegate function for when drive jumps to lower limit.
◆ OnStartSim()
|
protectedvirtual |
Reimplemented from realvirtual.realvirtualBehavior.
◆ OnXREndPlace()
void realvirtual.Drive.OnXREndPlace | ( | GameObject | placedobj | ) |
Resumes drive operation after XR/AR placement is completed.
IMPLEMENTS IXRPlaceable::OnXREndPlace
◆ OnXRInit()
void realvirtual.Drive.OnXRInit | ( | GameObject | placedobj | ) |
Initializes the drive for XR/AR placement operations.
IMPLEMENTS IXRPlaceable::OnXRInit
◆ OnXRStartPlace()
void realvirtual.Drive.OnXRStartPlace | ( | GameObject | placedobj | ) |
Stops the drive when XR/AR placement begins to prevent movement during positioning.
IMPLEMENTS IXRPlaceable::OnXRStartPlace
◆ SetPosition()
void realvirtual.Drive.SetPosition | ( | float | Position | ) |
Gets the current speed of the drive and updates the visual position.
◆ Stop()
void realvirtual.Drive.Stop | ( | ) |
Stops the drive at the current position.
Member Data Documentation
◆ _StopDrive
bool realvirtual.Drive._StopDrive |
Stops the Drive at the current position.
◆ Acceleration
float realvirtual.Drive.Acceleration |
The acceleration in millimeter per second^2.
◆ BlockDestination
bool realvirtual.Drive.BlockDestination |
If Block Drive is true it will not drive to its Target Positon, Jogging is possible.
◆ CurrentSpeed
float realvirtual.Drive.CurrentSpeed |
The current speed of the drive.
◆ Direction
DIRECTION realvirtual.Drive.Direction |
The direction in local coordinate system of the GameObject where the drive is attached to.
◆ IsAtLowerLimit
bool realvirtual.Drive.IsAtLowerLimit |
Is true if Drive is jogging and reaching lower Limit.
◆ IsAtTarget
bool realvirtual.Drive.IsAtTarget |
Is true if Drive is at target position.
◆ IsAtTargetSpeed
bool realvirtual.Drive.IsAtTargetSpeed |
Is true if Drive is running.
◆ IsAtUpperLimit
bool realvirtual.Drive.IsAtUpperLimit |
Is true if Drive is jogging and reaching upper Limit.
◆ IsPosition
float realvirtual.Drive.IsPosition |
current position, can be overwritten by DriveOverwrite or current position
◆ IsRunning
bool realvirtual.Drive.IsRunning |
Is true if Drive is running.
◆ IsSpeed
float realvirtual.Drive.IsSpeed |
current speed, can be overwritten by SpeedOverwrite or current position
The current position of the drive
◆ IsStopped
bool realvirtual.Drive.IsStopped |
Is true if Drive is stopped.
◆ JogBackward
bool realvirtual.Drive.JogBackward |
A jog bit for jogging backwards with the Target Speed.
◆ JogForward
bool realvirtual.Drive.JogForward |
A jog bit for jogging forward with the Target Speed.
◆ LowerLimit
float realvirtual.Drive.LowerLimit |
Lower Drive Limit, Upper and Lower = 0 if this should not be used.
◆ MoveThisRigidBody
bool realvirtual.Drive.MoveThisRigidBody |
If set to true the RigidBodies are moved (use it if moving) part has attached colliders, if false the transforms are moved.
◆ Offset
float realvirtual.Drive.Offset |
Start offset of the drive from zero position in millimeters or degrees.
◆ OnAfterDriveCalculation
DriveEvent realvirtual.Drive.OnAfterDriveCalculation |
Unity Event after calculating drive.
◆ OnBeforeDriveCalculation
DriveEvent realvirtual.Drive.OnBeforeDriveCalculation |
Unity Event before calculating drive.
◆ PositionOverwrite
bool realvirtual.Drive.PositionOverwrite |
true for overwriting position for replaying recordings or multiplayer
◆ ResetDrive
bool realvirtual.Drive.ResetDrive |
Resets the Drive to the zero position and stops all movements.
◆ ReverseDirection
bool realvirtual.Drive.ReverseDirection |
Set to true if Direction needs to be inverted.
◆ SmoothAcceleration
bool realvirtual.Drive.SmoothAcceleration |
if set to true the drive uses smooth acceleration with a sinoide function
◆ SpeedOverride
float realvirtual.Drive.SpeedOverride |
Factor for locally overriding the speed and acceleration of this drive.
◆ SpeedOverwrite
bool realvirtual.Drive.SpeedOverwrite |
true for overwriting speed (transportsurfaces) for replaying recordings or multiplayer
◆ SpeedScaleTransportSurface
float realvirtual.Drive.SpeedScaleTransportSurface |
Scale of the Speed for radial transportsurfaces to feed in mm/s on radius.
◆ StartPosition
float realvirtual.Drive.StartPosition |
Start Position off the Drive.
◆ TargetPosition
float realvirtual.Drive.TargetPosition |
The target position of the Drive.
◆ TargetSpeed
float realvirtual.Drive.TargetSpeed |
The target speed in millimeter / second of the Drive.
◆ TargetStartMove
bool realvirtual.Drive.TargetStartMove |
When changing to true the Drive is starting to move to the TargetPosition.
◆ UpperLimit
float realvirtual.Drive.UpperLimit |
Upper Drive Limit, Upper and Lower = 0 if this should not be used.
◆ UseAcceleration
bool realvirtual.Drive.UseAcceleration |
If set to true the drive uses the acceleration.
Event Documentation
◆ OnAtPosition
OnAtPositionEvent realvirtual.Drive.OnAtPosition |
Event triggered when drive reaches the destination position.
◆ OnJumpToLowerLimit
OnJumpToLowerLimitEvent realvirtual.Drive.OnJumpToLowerLimit |
Event triggered when drive jumps to lower limit.