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

VRTK_ObjectAutoGrab

Overview

It is possible to automatically grab an Interactable Object to a specific controller by applying the Object Auto Grab script to the controller that the object should be grabbed by default.

The Object Auto Grab script is attached to a Controller object within the [CameraRig] prefab and the Controller object requires the VRTK_InteractGrab script to be attached.

Inspector Parameters

  • Object To Grab: A game object (either within the scene or a prefab) that will be grabbed by the controller on game start.
  • Clone Grabbed Object: If this is checked then the Object To Grab will be cloned into a new object and attached to the controller leaving the existing object in the scene. This is required if the same object is to be grabbed to both controllers as a single object cannot be grabbed by different controllers at the same time. It is also required to clone a grabbed object if it is a prefab as it needs to exist within the scene to be grabbed.

Example

SteamVR_Unity_Toolkit/Examples/026_Controller_ForceHoldObject shows how to automatically grab a sword to each controller and also prevents the swords from being dropped so they are permanently attached to the user's controllers.