{"_id":"5b1f90b256942b0003484939","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:21:54.839Z","link_external":false,"link_url":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":2,"body":"## Overview\n\nDetermines if a GameObject can initiate a touch with an Interactable Object.\n\n**Required Components:**\n * `Rigidbody` - A Unity kinematic Rigidbody to determine when collisions happen between the Interact Touch GameObject and other valid colliders.\n\n**Script Usage:**\n * Place the `VRTK_InteractTouch` script on the controller script alias GameObject of the controller to track (e.g. Right Controller Script Alias).\n\n## Inspector Parameters\n\n * **Custom Collider Container:** An optional GameObject that contains the compound colliders to represent the touching object. If this is empty then the collider will be auto generated at runtime to match the SDK default controller.\n\n## Class Events\n\n * `ControllerStartTouchInteractableObject` - Emitted when the touch of a valid object has started.\n * `ControllerTouchInteractableObject` - Emitted when a valid object is touched.\n * `ControllerStartUntouchInteractableObject` - Emitted when the untouch of a valid object has started.\n * `ControllerUntouchInteractableObject` - Emitted when a valid object is no longer being touched.\n * `ControllerRigidbodyActivated` - Emitted when the controller rigidbody is activated.\n * `ControllerRigidbodyDeactivated` - Emitted when the controller rigidbody is deactivated.\n\n## Unity Events\n\nAdding the `VRTK_InteractTouch_UnityEvents` component to `VRTK_InteractTouch` 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## Event Payload\n\n * `VRTK_ControllerReference controllerReference` - The reference to the controller doing the interaction.\n * `GameObject target` - The GameObject of the Interactable Object that is being interacted with.\n\n## Class Methods\n\n### ForceTouch/1\n\n  > `public virtual void ForceTouch(GameObject obj)`\n\n * Parameters\n   * `GameObject obj` - The GameObject to attempt to force touch.\n * Returns\n   * _none_\n\nThe ForceTouch method will attempt to force the Interact Touch onto the given GameObject.\n\n### GetTouchedObject/0\n\n  > `public virtual GameObject GetTouchedObject()`\n\n * Parameters\n   * _none_\n * Returns\n   * `GameObject` - The GameObject of what is currently being touched by this Interact Touch.\n\nThe GetTouchedObject method returns the current GameObject being touched by the Interact Touch.\n\n### IsObjectInteractable/1\n\n  > `public virtual bool IsObjectInteractable(GameObject obj)`\n\n * Parameters\n   * `GameObject obj` - The GameObject to check to see if it's a valid Interactable Object.\n * Returns\n   * `bool` - Returns `true` if the given GameObjectis a valid Interactable Object.\n\nThe IsObjectInteractable method is used to check if a given GameObject is a valid Interactable Object.\n\n### ToggleControllerRigidBody/2\n\n  > `public virtual void ToggleControllerRigidBody(bool state, bool forceToggle = false)`\n\n * Parameters\n   * `bool state` - The state of whether the rigidbody is on or off. `true` toggles the rigidbody on and `false` turns it off.\n   * `bool forceToggle` - Determines if the rigidbody has been forced into it's new state by another script. This can be used to override other non-force settings. Defaults to `false`\n * Returns\n   * _none_\n\nThe ToggleControllerRigidBody method toggles the Interact Touch rigidbody's ability to detect collisions. If it is true then the controller rigidbody will collide with other collidable GameObjects.\n\n### IsRigidBodyActive/0\n\n  > `public virtual bool IsRigidBodyActive()`\n\n * Parameters\n   * _none_\n * Returns\n   * `bool` - Returns `true` if the rigidbody on the Interact Touch is currently active and able to affect other scene rigidbodies.\n\nThe IsRigidBodyActive method checks to see if the rigidbody on the Interact Touch is active and can affect other rigidbodies in the scene.\n\n### IsRigidBodyForcedActive/0\n\n  > `public virtual bool IsRigidBodyForcedActive()`\n\n * Parameters\n   * _none_\n * Returns\n   * `bool` - Returns `true` if the rigidbody is active and has been forced into the active state.\n\nThe IsRigidBodyForcedActive method checks to see if the rigidbody on the Interact Touch has been forced into the active state.\n\n### ForceStopTouching/0\n\n  > `public virtual void ForceStopTouching()`\n\n * Parameters\n   * _none_\n * Returns\n   * _none_\n\nThe ForceStopTouching method will stop the Interact Touch from touching an Interactable Object even if the Interact Touch is physically touching the Interactable Object.\n\n### ControllerColliders/0\n\n  > `public virtual Collider[] ControllerColliders()`\n\n * Parameters\n   * _none_\n * Returns\n   * `Collider[]` - An array of colliders that are associated with the controller.\n\nThe ControllerColliders method retrieves all of the associated colliders on the Interact Touch.\n\n### GetControllerType/0\n\n  > `public virtual SDK_BaseController.ControllerType GetControllerType()`\n\n * Parameters\n   * _none_\n * Returns\n   * `SDK_BaseController.ControllerType` - The type of controller that the Interact Touch is attached to.\n\nThe GetControllerType method is a shortcut to retrieve the current controller type the Interact Touch is attached to.\n\n## Example\n\n`VRTK/Examples/005_Controller/BasicObjectGrabbing` demonstrates the highlighting of objects that have the `VRTK_InteractableObject` script added to them to show the ability to highlight interactable objects when they are touched by the controllers.","excerpt":"","slug":"vrtk_interacttouch-1","type":"basic","title":"VRTK_InteractTouch"}

VRTK_InteractTouch


## Overview Determines if a GameObject can initiate a touch with an Interactable Object. **Required Components:** * `Rigidbody` - A Unity kinematic Rigidbody to determine when collisions happen between the Interact Touch GameObject and other valid colliders. **Script Usage:** * Place the `VRTK_InteractTouch` script on the controller script alias GameObject of the controller to track (e.g. Right Controller Script Alias). ## Inspector Parameters * **Custom Collider Container:** An optional GameObject that contains the compound colliders to represent the touching object. If this is empty then the collider will be auto generated at runtime to match the SDK default controller. ## Class Events * `ControllerStartTouchInteractableObject` - Emitted when the touch of a valid object has started. * `ControllerTouchInteractableObject` - Emitted when a valid object is touched. * `ControllerStartUntouchInteractableObject` - Emitted when the untouch of a valid object has started. * `ControllerUntouchInteractableObject` - Emitted when a valid object is no longer being touched. * `ControllerRigidbodyActivated` - Emitted when the controller rigidbody is activated. * `ControllerRigidbodyDeactivated` - Emitted when the controller rigidbody is deactivated. ## Unity Events Adding the `VRTK_InteractTouch_UnityEvents` component to `VRTK_InteractTouch` 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`. ## Event Payload * `VRTK_ControllerReference controllerReference` - The reference to the controller doing the interaction. * `GameObject target` - The GameObject of the Interactable Object that is being interacted with. ## Class Methods ### ForceTouch/1 > `public virtual void ForceTouch(GameObject obj)` * Parameters * `GameObject obj` - The GameObject to attempt to force touch. * Returns * _none_ The ForceTouch method will attempt to force the Interact Touch onto the given GameObject. ### GetTouchedObject/0 > `public virtual GameObject GetTouchedObject()` * Parameters * _none_ * Returns * `GameObject` - The GameObject of what is currently being touched by this Interact Touch. The GetTouchedObject method returns the current GameObject being touched by the Interact Touch. ### IsObjectInteractable/1 > `public virtual bool IsObjectInteractable(GameObject obj)` * Parameters * `GameObject obj` - The GameObject to check to see if it's a valid Interactable Object. * Returns * `bool` - Returns `true` if the given GameObjectis a valid Interactable Object. The IsObjectInteractable method is used to check if a given GameObject is a valid Interactable Object. ### ToggleControllerRigidBody/2 > `public virtual void ToggleControllerRigidBody(bool state, bool forceToggle = false)` * Parameters * `bool state` - The state of whether the rigidbody is on or off. `true` toggles the rigidbody on and `false` turns it off. * `bool forceToggle` - Determines if the rigidbody has been forced into it's new state by another script. This can be used to override other non-force settings. Defaults to `false` * Returns * _none_ The ToggleControllerRigidBody method toggles the Interact Touch rigidbody's ability to detect collisions. If it is true then the controller rigidbody will collide with other collidable GameObjects. ### IsRigidBodyActive/0 > `public virtual bool IsRigidBodyActive()` * Parameters * _none_ * Returns * `bool` - Returns `true` if the rigidbody on the Interact Touch is currently active and able to affect other scene rigidbodies. The IsRigidBodyActive method checks to see if the rigidbody on the Interact Touch is active and can affect other rigidbodies in the scene. ### IsRigidBodyForcedActive/0 > `public virtual bool IsRigidBodyForcedActive()` * Parameters * _none_ * Returns * `bool` - Returns `true` if the rigidbody is active and has been forced into the active state. The IsRigidBodyForcedActive method checks to see if the rigidbody on the Interact Touch has been forced into the active state. ### ForceStopTouching/0 > `public virtual void ForceStopTouching()` * Parameters * _none_ * Returns * _none_ The ForceStopTouching method will stop the Interact Touch from touching an Interactable Object even if the Interact Touch is physically touching the Interactable Object. ### ControllerColliders/0 > `public virtual Collider[] ControllerColliders()` * Parameters * _none_ * Returns * `Collider[]` - An array of colliders that are associated with the controller. The ControllerColliders method retrieves all of the associated colliders on the Interact Touch. ### GetControllerType/0 > `public virtual SDK_BaseController.ControllerType GetControllerType()` * Parameters * _none_ * Returns * `SDK_BaseController.ControllerType` - The type of controller that the Interact Touch is attached to. The GetControllerType method is a shortcut to retrieve the current controller type the Interact Touch is attached to. ## Example `VRTK/Examples/005_Controller/BasicObjectGrabbing` demonstrates the highlighting of objects that have the `VRTK_InteractableObject` script added to them to show the ability to highlight interactable objects when they are touched by the controllers.