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

VRTK_TrackObjectGrabAttach

extends VRTK_BaseGrabAttach

Overview

The Track Object Grab Attach script doesn't attach the object to the controller via a joint, instead it ensures the object tracks the direction of the controller.

This works well for items that are on hinged joints or objects that require to interact naturally with other scene rigidbodies.

Inspector Parameters

  • Detach Distance: The maximum distance the grabbing controller is away from the object before it is automatically dropped.
  • Velocity Limit: The maximum amount of velocity magnitude that can be applied to the object. Lowering this can prevent physics glitches if objects are moving too fast.
  • Angular Velocity Limit: The maximum amount of angular velocity magnitude that can be applied to the object. Lowering this can prevent physics glitches if objects are moving too fast.

Class Methods

StopGrab/1

public override void StopGrab(bool applyGrabbingObjectVelocity)

  • Parameters
  • bool applyGrabbingObjectVelocity - If true will apply the current velocity of the grabbing object to the grabbed object on release.
  • Returns
  • none

The StopGrab method ends the grab of the current object and cleans up the state.

CreateTrackPoint/4

public override Transform CreateTrackPoint(Transform controllerPoint, GameObject currentGrabbedObject, GameObject currentGrabbingObject, ref bool customTrackPoint)

  • Parameters
  • Transform controllerPoint - The point on the controller where the grab was initiated.
  • GameObject currentGrabbedObject - The object that is currently being grabbed.
  • GameObject currentGrabbingObject - The object that is currently doing the grabbing.
  • ref bool customTrackPoint - A reference to whether the created track point is an auto generated custom object.
  • Returns
  • Transform - The transform of the created track point.

The CreateTrackPoint method sets up the point of grab to track on the grabbed object.

ProcessUpdate/0

public override void ProcessUpdate()

  • Parameters
  • none
  • Returns
  • none

The ProcessUpdate method is run in every Update method on the interactable object. It is responsible for checking if the tracked object has exceeded it's detach distance.

ProcessFixedUpdate/0

public override void ProcessFixedUpdate()

  • Parameters
  • none
  • Returns
  • none

The ProcessFixedUpdate method is run in every FixedUpdate method on the interactable object. It applies velocity to the object to ensure it is tracking the grabbing object.

Example

VRTK/Examples/021_Controller_GrabbingObjectsWithJoints demonstrates this grab attach mechanic on the Chest handle and Fire Extinguisher body.