Guides

VRTK_BaseGrabAttach

Overview

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

Script Usage:

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

Inspector Parameters

  • Precision Grab: If this is checked then when the Interact Grab grabs the Interactable Object, it will grab it with precision and pick it up at the particular point on the Interactable Object that the Interact Touch is touching.
  • Right Snap Handle: A Transform provided as an empty GameObject which must be the child of the Interactable Object being grabbed and serves as an orientation point to rotate and position the grabbed Interactable Object in relation to the right handed Interact Grab. 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 Interactable Object will be grabbed at its central point. Not required for Precision Grab.
  • Left Snap Handle: A Transform provided as an empty GameObject which must be the child of the Interactable Object being grabbed and serves as an orientation point to rotate and position the grabbed Interactable Object in relation to the left handed Interact Grab. 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 Interactable Object will be grabbed at its central point. Not required for Precision Grab.
  • Throw Velocity With Attach Distance: If checked then when the Interactable Object is thrown, the distance between the Interactable Object's attach point and the Interact Grab's attach point will be used to calculate a faster throwing velocity.
  • Throw Multiplier: An amount to multiply the velocity of the given Interactable Object when it is thrown. This can also be used in conjunction with the Interact Grab Throw Multiplier to have certain Interactable 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 Interactable Object when it is first grabbed. This is useful if the Interactable Object could get stuck inside another GameObject when it is being grabbed.

Class Methods

IsTracked/0

public virtual 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 virtual 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 virtual 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 - The rigidbody attach point to check.
  • 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 Interactable Object.
  • Returns
    • none

The SetTrackPoint method sets the point on the grabbed Interactable 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 Interactable Object where the initial grab happened.

StartGrab/3

public virtual 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.

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 Interactable 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 GameObject that is currently being grabbed.
    • GameObject currentGrabbingObject - The GameObject 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.

ResetState/0

public virtual void ResetState()

  • Parameters
    • none
  • Returns
    • none

The ResetState method re-initializes the grab attach.