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

VRTK_BaseGrabAttach

Overview

The Base Grab Attach script is an abstract class that all grab attach script inherit.

As this is an abstract class, it cannot be applied directly to a game object and performs no logic.

Inspector Parameters

  • Precision Grab: If this is checked then when the controller grabs the object, it will grab it with precision and pick it up at the particular point on the object the controller is touching.
  • Right Snap Handle: A Transform provided as an empty game object which must be the child of the item being grabbed and serves as an orientation point to rotate and position the grabbed item in relation to the right handed controller. If no Right Snap Handle is provided but a Left Snap Handle is provided, then the Left Snap Handle will be used in place. If no Snap Handle is provided then the object will be grabbed at its central point. Not required for Precision Snap.
  • Left Snap Handle: A Transform provided as an empty game object which must be the child of the item being grabbed and serves as an orientation point to rotate and position the grabbed item in relation to the left handed controller. If no Left Snap Handle is provided but a Right Snap Handle is provided, then the Right Snap Handle will be used in place. If no Snap Handle is provided then the object will be grabbed at its central point. Not required for Precision Snap.
  • Throw Velocity With Attach Distance: If checked then when the object is thrown, the distance between the object's attach point and the controller's attach point will be used to calculate a faster throwing velocity.
  • Throw Multiplier: An amount to multiply the velocity of the given object when it is thrown. This can also be used in conjunction with the Interact Grab Throw Multiplier to have certain objects be thrown even further than normal (or thrown a shorter distance if a number below 1 is entered).
  • On Grab Collision Delay: The amount of time to delay collisions affecting the object when it is first grabbed. This is useful if a game object may get stuck inside another object when it is being grabbed.

Class Methods

IsTracked/0

public bool IsTracked()

  • Parameters
  • none
  • Returns
  • bool - Is true if the mechanic is of type tracked.

The IsTracked method determines if the grab attach mechanic is a track object type.

IsClimbable/0

public bool IsClimbable()

  • Parameters
  • none
  • Returns
  • bool - Is true if the mechanic is of type climbable.

The IsClimbable method determines if the grab attach mechanic is a climbable object type.

IsKinematic/0

public bool IsKinematic()

  • Parameters
  • none
  • Returns
  • bool - Is true if the mechanic is of type kinematic.

The IsKinematic method determines if the grab attach mechanic is a kinematic object type.

ValidGrab/1

public virtual bool ValidGrab(Rigidbody checkAttachPoint)

  • Parameters
  • Rigidbody checkAttachPoint -
  • Returns
  • bool - Always returns true for the base check.

The ValidGrab method determines if the grab attempt is valid.

SetTrackPoint/1

public virtual void SetTrackPoint(Transform givenTrackPoint)

  • Parameters
  • Transform givenTrackPoint - The track point to set on the grabbed object.
  • Returns
  • none

The SetTrackPoint method sets the point on the grabbed object where the grab is happening.

SetInitialAttachPoint/1

public virtual void SetInitialAttachPoint(Transform givenInitialAttachPoint)

  • Parameters
  • Transform givenInitialAttachPoint - The point where the initial grab took place.
  • Returns
  • none

The SetInitialAttachPoint method sets the point on the grabbed object where the initial grab happened.

StartGrab/3

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

  • Parameters
  • GameObject grabbingObject - The object that is doing the grabbing.
  • GameObject givenGrabbedObject - The object 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 - Is 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 object is grabbed.

StopGrab/1

public virtual 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 virtual 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 virtual void ProcessUpdate()

  • Parameters
  • none
  • Returns
  • none

The ProcessUpdate method is run in every Update method on the interactable object.

ProcessFixedUpdate/0

public virtual void ProcessFixedUpdate()

  • Parameters
  • none
  • Returns
  • none

The ProcessFixedUpdate method is run in every FixedUpdate method on the interactable object.