{"_id":"58796783cd4a9c37007c976b","__v":0,"project":"571fa55ca0acd42000af9545","user":"571fa519db52d01700f5cf3d","category":{"_id":"58796781cd4a9c37007c96f6","__v":0,"version":"58796781cd4a9c37007c96ef","project":"571fa55ca0acd42000af9545","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2017-01-01T16:50:06.279Z","from_sync":false,"order":8,"slug":"grab-attach-mechanics","title":"Grab Attach Mechanics"},"parentDoc":null,"version":{"_id":"58796781cd4a9c37007c96ef","__v":4,"project":"571fa55ca0acd42000af9545","createdAt":"2017-01-13T23:49:21.393Z","releaseDate":"2017-01-13T23:49:21.393Z","categories":["58796781cd4a9c37007c96f0","58796781cd4a9c37007c96f1","58796781cd4a9c37007c96f2","58796781cd4a9c37007c96f3","58796781cd4a9c37007c96f4","58796781cd4a9c37007c96f5","58796781cd4a9c37007c96f6","58796781cd4a9c37007c96f7","58796781cd4a9c37007c96f8","58796781cd4a9c37007c96f9","58796781cd4a9c37007c96fa","58796781cd4a9c37007c96fb","58796781cd4a9c37007c96fc","58796781cd4a9c37007c96fd","58796781cd4a9c37007c96fe","58796781cd4a9c37007c96ff","58796781cd4a9c37007c9700","58b157ca1756cf370022f90d","58b1596f5dae732f00adeca2","58b1605a5dae732f00adecb1"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"Mukota","version_clean":"3.1.0","version":"3.1.0"},"updates":[],"next":{"pages":[],"description":""},"createdAt":"2017-01-01T16:52:29.154Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":7,"body":"> extends [VRTK_BaseGrabAttach](doc:vrtk_basegrabattach)\n\n## Overview\n\nThe Track Object Grab Attach script doesn't attach the object to the controller via a joint, instead it ensures the object tracks the direction of the controller.\n\nThis works well for items that are on hinged joints or objects that require to interact naturally with other scene rigidbodies.\n\n## Inspector Parameters\n\n * **Detach Distance:** The maximum distance the grabbing controller is away from the object before it is automatically dropped.\n * **Velocity Limit:** The maximum amount of velocity magnitude that can be applied to the object. Lowering this can prevent physics glitches if objects are moving too fast.\n * **Angular Velocity Limit:** The maximum amount of angular velocity magnitude that can be applied to the object. Lowering this can prevent physics glitches if objects are moving too fast.\n\n## Class Methods\n\n### StopGrab/1\n\n  > `public override void StopGrab(bool applyGrabbingObjectVelocity)`\n\n  * Parameters\n   * `bool applyGrabbingObjectVelocity` - If true will apply the current velocity of the grabbing object to the grabbed object on release.\n  * Returns\n   * _none_\n\nThe StopGrab method ends the grab of the current object and cleans up the state.\n\n### CreateTrackPoint/4\n\n  > `public override Transform CreateTrackPoint(Transform controllerPoint, GameObject currentGrabbedObject, GameObject currentGrabbingObject, ref bool customTrackPoint)`\n\n  * Parameters\n   * `Transform controllerPoint` - The point on the controller where the grab was initiated.\n   * `GameObject currentGrabbedObject` - The object that is currently being grabbed.\n   * `GameObject currentGrabbingObject` - The object that is currently doing the grabbing.\n   * `ref bool customTrackPoint` - A reference to whether the created track point is an auto generated custom object.\n  * Returns\n   * `Transform` - The transform of the created track point.\n\nThe CreateTrackPoint method sets up the point of grab to track on the grabbed object.\n\n### ProcessUpdate/0\n\n  > `public override void ProcessUpdate()`\n\n  * Parameters\n   * _none_\n  * Returns\n   * _none_\n\nThe 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.\n\n### ProcessFixedUpdate/0\n\n  > `public override void ProcessFixedUpdate()`\n\n  * Parameters\n   * _none_\n  * Returns\n   * _none_\n\nThe 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.\n\n## Example\n\n`VRTK/Examples/021_Controller_GrabbingObjectsWithJoints` demonstrates this grab attach mechanic on the Chest handle and Fire Extinguisher body.","excerpt":"","slug":"vrtk_trackobjectgrabattach","type":"basic","title":"VRTK_TrackObjectGrabAttach"}

VRTK_TrackObjectGrabAttach


> extends [VRTK_BaseGrabAttach](doc:vrtk_basegrabattach) ## Overview The Track Object Grab Attach script doesn't attach the object to the controller via a joint, instead it ensures the object tracks the direction of the controller. This works well for items that are on hinged joints or objects that require to interact naturally with other scene rigidbodies. ## Inspector Parameters * **Detach Distance:** The maximum distance the grabbing controller is away from the object before it is automatically dropped. * **Velocity Limit:** The maximum amount of velocity magnitude that can be applied to the object. Lowering this can prevent physics glitches if objects are moving too fast. * **Angular Velocity Limit:** The maximum amount of angular velocity magnitude that can be applied to the object. Lowering this can prevent physics glitches if objects are moving too fast. ## Class Methods ### 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 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 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 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.