{"_id":"5b1f90c8fd653400031d960e","project":"571fa55ca0acd42000af9545","version":{"_id":"5b1f8576c2505d00031254db","project":"571fa55ca0acd42000af9545","__v":4,"forked_from":"594949e52be16d0026ec04cd","createdAt":"2017-06-20T16:14:29.816Z","releaseDate":"2017-06-20T16:14:29.816Z","categories":["5b1f8576c2505d0003125424","5b1f8576c2505d0003125425","5b1f8576c2505d0003125426","5b1f8576c2505d0003125427","5b1f8576c2505d0003125428","5b1f8576c2505d0003125429","5b1f8576c2505d000312542a","5b1f8576c2505d000312542b","5b1f8576c2505d000312542c","5b1f8576c2505d000312542d","5b1f8576c2505d000312542e","5b1f8576c2505d000312542f","5b1f8576c2505d0003125430","5b1f8576c2505d0003125431","5b1f8576c2505d0003125432","5b1f8576c2505d0003125433","5b1f8576c2505d0003125434","5b1f8576c2505d0003125435","5b1f8576c2505d0003125436","5b1f8576c2505d0003125437","5b1f8576c2505d0003125438","5b1f8aab9c683000032979e7","5b1f8b2f3073470003ffa5da","5b1f8bd9fd653400031d94f4","5b1f900bd4c5f000036b57bd"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"Mangalica","version_clean":"3.3.0","version":"3.3.0"},"category":{"_id":"5b1f900bd4c5f000036b57bd","project":"571fa55ca0acd42000af9545","version":"5b1f8576c2505d00031254db","__v":0,"sync":{"url":"","isSync":false},"reference":false,"createdAt":"2018-06-12T09:19:07.462Z","from_sync":false,"order":6,"slug":"interactors","title":"Interactors"},"user":"571fa519db52d01700f5cf3d","githubsync":"","__v":0,"parentDoc":null,"updates":[],"next":{"pages":[],"description":""},"createdAt":"2018-06-12T09:22:16.249Z","link_external":false,"link_url":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":4,"body":"## Overview\n\nDetermines if the Interact Touch can initiate a grab with the touched Interactable Object.\n\n**Required Components:**\n * `VRTK_InteractTouch` - The touch component to determine when a valid touch has taken place to denote a grab can occur. This must be applied on the same GameObject as this script if one is not provided via the `Interact Touch` parameter.\n\n**Optional Components:**\n * `VRTK_ControllerEvents` - The events component to listen for the button presses on. This must be applied on the same GameObject as this script if one is not provided via the `Controller Events` parameter.\n\n**Script Usage:**\n * Place the `VRTK_InteractGrab` script on either:\n   * The GameObject with the Interact Touch and Controller Events scripts.\n   * Any other scene GameObject and provide a valid `VRTK_ControllerEvents` component to the `Controller Events` parameter and a valid `VRTK_InteractTouch` component to the `Interact Touch` parameter of this script.\n\n## Inspector Parameters\n\n * **Grab Button:** The button used to grab/release a touched Interactable Object.\n * **Grab Precognition:** An amount of time between when the grab button is pressed to when the controller is touching an Interactable Object to grab it.\n * **Throw Multiplier:** An amount to multiply the velocity of any Interactable Object being thrown.\n * **Create Rigid Body When Not Touching:** If this is checked and the Interact Touch is not touching an Interactable Object when the grab button is pressed then a Rigidbody is added to the interacting object to allow it to push other Rigidbody objects around.\n * **Controller Attach Point:** The rigidbody point on the controller model to snap the grabbed Interactable Object to. If blank it will be set to the SDK default.\n * **Controller Events:** The Controller Events to listen for the events on. If the script is being applied onto a controller then this parameter can be left blank as it will be auto populated by the controller the script is on at runtime.\n * **Interact Touch:** The Interact Touch to listen for touches on. If the script is being applied onto a controller then this parameter can be left blank as it will be auto populated by the controller the script is on at runtime.\n\n## Class Events\n\n * `GrabButtonPressed` - Emitted when the grab button is pressed.\n * `GrabButtonReleased` - Emitted when the grab button is released.\n * `ControllerStartGrabInteractableObject` - Emitted when a grab of a valid object is started.\n * `ControllerGrabInteractableObject` - Emitted when a valid object is grabbed.\n * `ControllerStartUngrabInteractableObject` - Emitted when a ungrab of a valid object is started.\n * `ControllerUngrabInteractableObject` - Emitted when a valid object is released from being grabbed.\n\n## Unity Events\n\nAdding the `VRTK_InteractGrab_UnityEvents` component to `VRTK_InteractGrab` object allows access to `UnityEvents` that will react identically to the Class Events.\n\n * All C# delegate events are mapped to a Unity Event with the `On` prefix. e.g. `MyEvent` -> `OnMyEvent`.\n\n## Class Methods\n\n### IsGrabButtonPressed/0\n\n  > `public virtual bool IsGrabButtonPressed()`\n\n * Parameters\n   * _none_\n * Returns\n   * `bool` - Returns `true` if the grab alias button is being held down.\n\nThe IsGrabButtonPressed method determines whether the current grab alias button is being pressed down.\n\n### ForceRelease/1\n\n  > `public virtual void ForceRelease(bool applyGrabbingObjectVelocity = false)`\n\n * Parameters\n   * `bool applyGrabbingObjectVelocity` - If this is true then upon releasing the Interactable Object any velocity on the Interact Touch GameObject will be applied to the Interactable Object to essentiall throw it. Defaults to `false`.\n * Returns\n   * _none_\n\nThe ForceRelease method will force the Interact Grab to stop grabbing the currently grabbed Interactable Object.\n\n### AttemptGrab/0\n\n  > `public virtual void AttemptGrab()`\n\n * Parameters\n   * _none_\n * Returns\n   * _none_\n\nThe AttemptGrab method will attempt to grab the currently touched Interactable Object without needing to press the grab button on the controller.\n\n### GetGrabbedObject/0\n\n  > `public virtual GameObject GetGrabbedObject()`\n\n * Parameters\n   * _none_\n * Returns\n   * `GameObject` - The game object of what is currently being grabbed by this controller.\n\nThe GetGrabbedObject method returns the current Interactable Object being grabbed by the this Interact Grab.\n\n### ForceControllerAttachPoint/1\n\n  > `public virtual void ForceControllerAttachPoint(Rigidbody forcedAttachPoint)`\n\n * Parameters\n   * `Rigidbody forcedAttachPoint` - The rigidbody to use as the controller attach point.\n * Returns\n   * _none_\n\nThe ForceControllerAttachPoint method updates the rigidbody being used as the controller grab attach position.\n\n## Example\n\n`VRTK/Examples/005_Controller/BasicObjectGrabbing` demonstrates the grabbing of interactable objects that have the `VRTK_InteractableObject` script attached to them. The objects can be picked up and thrown around.\n\n`VRTK/Examples/013_Controller_UsingAndGrabbingMultipleObjects` demonstrates that each controller can grab and use objects independently and objects can also be toggled to their use state simultaneously.\n\n`VRTK/Examples/014_Controller_SnappingObjectsOnGrab` demonstrates the different mechanisms for snapping a grabbed object to the controller.","excerpt":"","slug":"vrtk_interactgrab-1","type":"basic","title":"VRTK_InteractGrab"}
## Overview Determines if the Interact Touch can initiate a grab with the touched Interactable Object. **Required Components:** * `VRTK_InteractTouch` - The touch component to determine when a valid touch has taken place to denote a grab can occur. This must be applied on the same GameObject as this script if one is not provided via the `Interact Touch` parameter. **Optional Components:** * `VRTK_ControllerEvents` - The events component to listen for the button presses on. This must be applied on the same GameObject as this script if one is not provided via the `Controller Events` parameter. **Script Usage:** * Place the `VRTK_InteractGrab` script on either: * The GameObject with the Interact Touch and Controller Events scripts. * Any other scene GameObject and provide a valid `VRTK_ControllerEvents` component to the `Controller Events` parameter and a valid `VRTK_InteractTouch` component to the `Interact Touch` parameter of this script. ## Inspector Parameters * **Grab Button:** The button used to grab/release a touched Interactable Object. * **Grab Precognition:** An amount of time between when the grab button is pressed to when the controller is touching an Interactable Object to grab it. * **Throw Multiplier:** An amount to multiply the velocity of any Interactable Object being thrown. * **Create Rigid Body When Not Touching:** If this is checked and the Interact Touch is not touching an Interactable Object when the grab button is pressed then a Rigidbody is added to the interacting object to allow it to push other Rigidbody objects around. * **Controller Attach Point:** The rigidbody point on the controller model to snap the grabbed Interactable Object to. If blank it will be set to the SDK default. * **Controller Events:** The Controller Events to listen for the events on. If the script is being applied onto a controller then this parameter can be left blank as it will be auto populated by the controller the script is on at runtime. * **Interact Touch:** The Interact Touch to listen for touches on. If the script is being applied onto a controller then this parameter can be left blank as it will be auto populated by the controller the script is on at runtime. ## Class Events * `GrabButtonPressed` - Emitted when the grab button is pressed. * `GrabButtonReleased` - Emitted when the grab button is released. * `ControllerStartGrabInteractableObject` - Emitted when a grab of a valid object is started. * `ControllerGrabInteractableObject` - Emitted when a valid object is grabbed. * `ControllerStartUngrabInteractableObject` - Emitted when a ungrab of a valid object is started. * `ControllerUngrabInteractableObject` - Emitted when a valid object is released from being grabbed. ## Unity Events Adding the `VRTK_InteractGrab_UnityEvents` component to `VRTK_InteractGrab` object allows access to `UnityEvents` that will react identically to the Class Events. * All C# delegate events are mapped to a Unity Event with the `On` prefix. e.g. `MyEvent` -> `OnMyEvent`. ## Class Methods ### IsGrabButtonPressed/0 > `public virtual bool IsGrabButtonPressed()` * Parameters * _none_ * Returns * `bool` - Returns `true` if the grab alias button is being held down. The IsGrabButtonPressed method determines whether the current grab alias button is being pressed down. ### ForceRelease/1 > `public virtual void ForceRelease(bool applyGrabbingObjectVelocity = false)` * Parameters * `bool applyGrabbingObjectVelocity` - If this is true then upon releasing the Interactable Object any velocity on the Interact Touch GameObject will be applied to the Interactable Object to essentiall throw it. Defaults to `false`. * Returns * _none_ The ForceRelease method will force the Interact Grab to stop grabbing the currently grabbed Interactable Object. ### AttemptGrab/0 > `public virtual void AttemptGrab()` * Parameters * _none_ * Returns * _none_ The AttemptGrab method will attempt to grab the currently touched Interactable Object without needing to press the grab button on the controller. ### GetGrabbedObject/0 > `public virtual GameObject GetGrabbedObject()` * Parameters * _none_ * Returns * `GameObject` - The game object of what is currently being grabbed by this controller. The GetGrabbedObject method returns the current Interactable Object being grabbed by the this Interact Grab. ### ForceControllerAttachPoint/1 > `public virtual void ForceControllerAttachPoint(Rigidbody forcedAttachPoint)` * Parameters * `Rigidbody forcedAttachPoint` - The rigidbody to use as the controller attach point. * Returns * _none_ The ForceControllerAttachPoint method updates the rigidbody being used as the controller grab attach position. ## Example `VRTK/Examples/005_Controller/BasicObjectGrabbing` demonstrates the grabbing of interactable objects that have the `VRTK_InteractableObject` script attached to them. The objects can be picked up and thrown around. `VRTK/Examples/013_Controller_UsingAndGrabbingMultipleObjects` demonstrates that each controller can grab and use objects independently and objects can also be toggled to their use state simultaneously. `VRTK/Examples/014_Controller_SnappingObjectsOnGrab` demonstrates the different mechanisms for snapping a grabbed object to the controller.