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.
Class Variables
public enum ButtonDirection
- 3D Control Button Directionsautodetect
- Attempt to auto detect the axisx
- X axisy
- Y axisz
- Z axisnegX
- Negative X axisnegY
- Negative Y axisnegZ
- Negative Z axis
Class Events
Pushed
- Emitted when the 3D Button has reached it's activation distance.
Unity Events
Adding the VRTK_Button_UnityEvents
component to VRTK_Button
object allows access to UnityEvents
that will react identically to the Class Events.
OnPushed
- Emits the Pushed class event.
Event Payload
float value
- The current value being reported by the control.float normalizedValue
- The normalized value being reported by the control.
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