Guides
These docs are for v3.2.0. Click to read the latest docs for v3.3.0.

VRTK_Lever

extends VRTK_Control

Overview

Attaching the script to a game object will allow the user to interact with it as if it were a lever. The direction can be freely set.

The script will instantiate the required Rigidbody, Interactable and HingeJoint components automatically in case they do not exist yet. The joint is very tricky to setup automatically though and will only work in straight forward cases. If there are any issues, then create the HingeJoint component manually and configure it as needed.

Inspector Parameters

  • Connected To: An optional game object to which the lever will be connected. If the game object moves the lever will follow along.
  • Direction: The axis on which the lever should rotate. All other axis will be frozen.
  • Min Angle: The minimum angle of the lever counted from its initial position.
  • Max Angle: The maximum angle of the lever counted from its initial position.
  • Step Size: The increments in which lever values can change.
  • Released Friction: The amount of friction the lever will have whilst swinging when it is not grabbed.
  • Grabbed Friction: The amount of friction the lever will have whilst swinging when it is grabbed.

Example

VRTK/Examples/025_Controls_Overview has a couple of levers that can be grabbed and moved. One lever is horizontal and the other is vertical.