VRTK_TrackObjectGrabAttach
extends VRTK_BaseGrabAttach
Overview
Applies velocity to the grabbed Interactable Object to ensure it tracks the position of the grabbing object.
The Interactable Object follows the grabbing object based on velocity being applied and therefore fully interacts with all other scene Colliders but not at a true 1:1 tracking.
Script Usage:
- Place the
VRTK_TrackObjectGrabAttach
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
Grab Attach Mechanic Script
parameter to denote use of the grab mechanic.
Inspector Parameters
- Detach Distance: The maximum distance the grabbing object is away from the Interactable Object before it is automatically dropped.
- Velocity Limit: The maximum amount of velocity magnitude that can be applied to the Interactable Object. Lowering this can prevent physics glitches if Interactable Objects are moving too fast.
- Angular Velocity Limit: The maximum amount of angular velocity magnitude that can be applied to the Interactable Object. Lowering this can prevent physics glitches if Interactable Objects are moving too fast.
- Max Distance Delta: The maximum difference in distance to the tracked position.
Class Methods
StopGrab/1
public override void StopGrab(bool applyGrabbingObjectVelocity)
- Parameters
bool applyGrabbingObjectVelocity
- Iftrue
will apply the current velocity of the grabbing object to the grabbed Interactable Object on release.
- Returns
- none
The StopGrab method ends the grab of the current Interactable 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 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 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.
Updated less than a minute ago