Guides

VRTK_BaseJointGrabAttach

extends VRTK_BaseGrabAttach

Overview

Provides a base that all joint based grab attach mechanics can inherit from.

Script Usage:

This is an abstract class that is to be inherited to a concrete class that provides joint based grab attach functionality, therefore this script should not be directly used.

Inspector Parameters

  • Destroy Immediately On Throw: Determines whether the joint should be destroyed immediately on release or whether to wait till the end of the frame before being destroyed.

Class Methods

ValidGrab/1

public override bool ValidGrab(Rigidbody checkAttachPoint)

  • Parameters
    • Rigidbody checkAttachPoint - The rigidbody attach point to check.
  • Returns
    • bool - Returns true if there is no current grab happening, or the grab is initiated by another grabbing object.

The ValidGrab method determines if the grab attempt is valid.

StartGrab/3

public override bool StartGrab(GameObject grabbingObject, GameObject givenGrabbedObject, Rigidbody givenControllerAttachPoint)

  • Parameters
    • GameObject grabbingObject - The GameObject that is doing the grabbing.
    • GameObject givenGrabbedObject - The GameObject that is being grabbed.
    • Rigidbody givenControllerAttachPoint - The point on the grabbing object that the grabbed object should be attached to after grab occurs.
  • Returns
    • bool - Returns true if the grab is successful, false if the grab is unsuccessful.

The StartGrab method sets up the grab attach mechanic as soon as an Interactable Object is grabbed. It is also responsible for creating the joint on the grabbed object.

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 Interactable Object and cleans up the state. It is also responsible for removing the joint from the grabbed object.