PushButton is an interactable button that uses physics to push and is synchronised between different users.
For an overview of how our SDK deals with interactions, please see Interaction Overview.
PushButton uses physics (a Rigidbody and a Collider ) to enable interaction. When a VR user's hand comes in close proximity to the button, it will automatically change into a pointing state to make pressing easier. The tip of the index finger contains a collider, which will physically push the button on collision. Once a button is pressed, a message is sent to all users in a scene.
PushButton also supports reactions, which allows logic operations to be integrated, 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>
- Set Sync Values to Position
- Add a child object and then add the Mesh that will move down as the button is pressed to the new child.
- Add one or more colliders (BoxCollider is best)
- Set the Sensitivity (see below)
- Set the correct Axis (see below)
If the button does not move, or moves oddly:
- Is the object's resting position and rotation reset to 0's?
- Ensure that the correct Axis is being used
- Do you have a collider on your GameObject? This is necessary for the SDK to detect engagement and for the Rigidbody to work.
Note: When a collider is missing, you will not see the hand disappear when the trigger is pulled.
- Do you have duplicate scene indices? You can check this on the Scene Object .
- Do you have another collider near that might prevent movement/rotation?
- Check if any requirements are set up, and are they all met (they should all be green when in play mode in the Editor Inspector).
PushButton component provides several properties that control its behaviour:
|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 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 maximum number of units the mesh can move downwards.|
|The valid direction of movement when the mesh is pressed downwards.|
Valid choices are:
PosX : The X axis (red)
PosY : The Y axis (green)
PosZ : The Z axis (blue)
NegX : The negative X axis (red)
NegY : The negative Y axis (green)
NegZ : The negative Z axis (blue)
In the picture above, the Button has the green axis pointing upwards, so the Axis setting should be NegY
Immerse SDK Class Library
More detail in ImmerseSDK.Interaction.PushButton class
Try out this component in the Examples project
Examples (menu) > Interactions > Load Button Example
Updated 4 months ago