A ToggleSwitch is a synchronised interactable switch that does not use Unity physics and has only an "On" and a "Off" state. It users a collider (with no physics) and is synchronised between different users. It is essentially a button but it looks like a switch and will automatically animate using a rotation.
For an overview of how the Immerse SDK deals with interactions, please read the Interaction Overview section.
ToggleSwitch uses only a collider (no physics) to enable interaction. When a VR user's hand comes in close proximity to the object, it will automatically change into a pointing state to make pressing easier. The tip of the index finger contains a collider, which will "push" the switch on collision. The switch will automatically animate to "On" or "Off" by a rotation. Once a switch is pressed, a message is sent to all users in a scene.
ToggleSwitch also supports reactions, which allows logic operations to be initiated, when the button is pressed.
- Select a new
- Reset the Position, Rotation and Scale of the Object. Ensure Position is set to <0, 0, 0>
- Add a child object and then add the Mesh that will rotate as the switch is pressed.
- Add one or more colliders (BoxCollider is best)
- Set the Throw (see below)
- Set the correct Axis (see below)
If the switch does not move, or moves unexpectedly:
- Check the object's resting position and rotation are reset to 0's?
- Ensure that the correct Axis is being used
- Check there's a collider on the GameObject - this is necessary for the Immerse SDK to detect engagement and for the Rigidbody to function correctly.
Note: If a collider is missing, the user's hand will not disappear when the trigger is pulled.
- Are there duplicate scene indices? Check the Scene Object to find out.
- Is there a nearby collider which is preventing movement and/or rotation?
- Check that requirements are set up, and are they all met (they should all be green when in play mode in the Editor Inspector).
Immerse SDK Class Library
More detail in ImmerseSDK.Interaction.ToggleSwitch class
|When enabled, this component instance will log verbosely to the console (only in the Editor). This is useful for debugging, but can have a detrimental effect on the framerate as verbose logging sometimes logs every frame.|
|The object's unique index - this will be automatically set by the Immerse SDK and should not be edited.|
|Only allows interaction if a Local user or their hand is touching the object|
|This setting is only used when the button is a child of a Pickup. In this case, the button can only be pressed when the Pickup is held in the other hand.|
|A set of requirements that need to be met to allow interaction; can be used to disable the object until a particular state is reached. See Interaction Requirements for more details.|
|The amount of rotation between "On" and "Off" states around the axis specified in the |
|The axis used for rotation to indicate "On" and "Off" states.|
Updated 4 months ago