VRTK_Button
extends VRTK_Control
Overview
Attaching the script to a game object will allow the user to interact with it as if it were a push button. The direction into which the button should be pushable can be freely set and auto-detection is supported. Since this is physics-based there needs to be empty space in the push direction so that the button can move.
The script will instantiate the required Rigidbody and ConstantForce components automatically in case they do not exist yet.
Inspector Parameters
- Connected To: An optional game object to which the button will be connected. If the game object moves the button will follow along.
- Direction: The axis on which the button should move. All other axis will be frozen.
- Activation Distance: The local distance the button needs to be pushed until a push event is triggered.
- Button Strength: The amount of force needed to push the button down as well as the speed with which it will go back into its original position.
Unity Events
OnPush
- Emitted when the button is successfully pushed.
Example
VRTK/Examples/025_Controls_Overview
shows a collection of pressable buttons that are interacted with by activating the rigidbody on the controller by pressing the grab button without grabbing an object.
Updated less than a minute ago