Guides

VRTK_ControlDirectionGrabAction

extends VRTK_BaseGrabAction

Overview

Controls the facing direction of the grabbed Interactable Object to rotate in the direction of the secondary grabbing object.

Rotation will only occur correctly if the Interactable Object forward is correctly aligned to the world z-axis and the up is correctly aligned to the world y-axis. It is also not possible to control the direction of an Interactable Object that uses the Joint based grab mechanics.

Script Usage:

  • Place the VRTK_ControlDirectionGrabAction script on either:
    • The GameObject of the Interactable Object to detect interactions on.
    • Any other scene GameObject and then link that GameObject to the Interactable Objects Secondary Grab Action Script parameter to denote use of the secondary grab action.

Inspector Parameters

  • Ungrab Distance: The distance the secondary controller must move away from the original grab position before the secondary controller auto ungrabs the object.
  • Release Snap Speed: The speed in which the object will snap back to it's original rotation when the secondary controller stops grabbing it. 0 for instant snap, infinity for no snap back.
  • Lock Z Rotation: Prevent the secondary controller rotating the grabbed object through it's z-axis.

Class Methods

Initialise/5

public override void Initialise(VRTK_InteractableObject currentGrabbdObject, VRTK_InteractGrab currentPrimaryGrabbingObject, VRTK_InteractGrab currentSecondaryGrabbingObject, Transform primaryGrabPoint, Transform secondaryGrabPoint)

  • Parameters
    • VRTK_InteractableObject currentGrabbdObject - The Interactable Object script for the object currently being grabbed by the primary grabbing object.
    • VRTK_InteractGrab currentPrimaryGrabbingObject - The Interact Grab script for the object that is associated with the primary grabbing object.
    • VRTK_InteractGrab currentSecondaryGrabbingObject - The Interact Grab script for the object that is associated with the secondary grabbing object.
    • Transform primaryGrabPoint - The point on the Interactable Object where the primary Interact Grab initially grabbed the Interactable Object.
    • Transform secondaryGrabPoint - The point on the Interactable Object where the secondary Interact Grab initially grabbed the Interactable Object.
  • Returns
    • none

The Initalise method is used to set up the state of the secondary action when the object is initially grabbed by a secondary controller.

ResetAction/0

public override void ResetAction()

  • Parameters
    • none
  • Returns
    • none

The ResetAction method is used to reset the secondary action when the Interactable Object is no longer grabbed by a secondary Interact Grab.

OnDropAction/0

public override void OnDropAction()

  • Parameters
    • none
  • Returns
    • none

The OnDropAction method is executed when the current grabbed Interactable Object is dropped and can be used up to clean up any secondary grab actions.

ProcessUpdate/0

public override void ProcessUpdate()

  • Parameters
    • none
  • Returns
    • none

The ProcessUpdate method runs in every Update on the Interactable Object whilst it is being grabbed by a secondary Interact Grab.

ProcessFixedUpdate/0

public override void ProcessFixedUpdate()

  • Parameters
    • none
  • Returns
    • none

The ProcessFixedUpdate method runs in every FixedUpdate on the Interactable Object whilst it is being grabbed by a secondary Interact Grab and influences the rotation of the Interactable Object.

Example

VRTK/Examples/043_Controller_SecondaryControllerActions demonstrates the ability to grab an object with one controller and control their direction with the second controller.