{"__v":0,"_id":"58796782cd4a9c37007c9743","category":{"version":"58796781cd4a9c37007c96ef","project":"571fa55ca0acd42000af9545","_id":"58796781cd4a9c37007c96f4","__v":0,"sync":{"url":"","isSync":false},"reference":false,"createdAt":"2017-01-01T16:45:52.489Z","from_sync":false,"order":6,"slug":"interactions","title":"Interactions"},"parentDoc":null,"project":"571fa55ca0acd42000af9545","user":"571fa519db52d01700f5cf3d","version":{"__v":4,"_id":"58796781cd4a9c37007c96ef","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:47:05.504Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":4,"body":"## Overview\n\nThe Interact Touch script is usually applied to a Controller and provides a collider to know when the controller is touching something.\n\nColliders are created for the controller and by default the selected controller SDK will have a set of colliders for the given default controller of that SDK.\n\nA custom collider can be provided by the Custom Rigidbody Object parameter.\n\n## Inspector Parameters\n\n * **Custom Rigidbody Object:** If a custom rigidbody and collider for the rigidbody are required, then a gameobject containing a rigidbody and collider can be passed into this parameter. If this is empty then the rigidbody and collider will be auto generated at runtime to match the SDK default controller.\n\n## Class Events\n\n * `ControllerTouchInteractableObject` - Emitted when a valid object is touched.\n * `ControllerUntouchInteractableObject` - Emitted when a valid object is no longer being touched.\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 * `OnControllerTouchInteractableObject` - Emits the ControllerTouchInteractableObject class event.\n * `OnControllerUntouchInteractableObject` - Emits the ControllerUntouchInteractableObject class event.\n\n## Event Payload\n\n * `uint controllerIndex` - The index of the controller doing the interaction.\n * `GameObject target` - The GameObject of the interactable object that is being interacted with by the controller.\n\n## Class Methods\n\n### ForceTouch/1\n\n  > `public void ForceTouch(GameObject obj)`\n\n  * Parameters\n   * `GameObject obj` - The game object to attempt to force touch.\n  * Returns\n   * _none_\n\nThe ForceTouch method will attempt to force the controller to touch the given game object. This is useful if an object that isn't being touched is required to be grabbed or used as the controller doesn't physically have to be touching it to be forced to interact with it.\n\n### GetTouchedObject/0\n\n  > `public GameObject GetTouchedObject()`\n\n  * Parameters\n   * _none_\n  * Returns\n   * `GameObject` - The game object of what is currently being touched by this controller.\n\nThe GetTouchedObject method returns the current object being touched by the controller.\n\n### IsObjectInteractable/1\n\n  > `public bool IsObjectInteractable(GameObject obj)`\n\n  * Parameters\n   * `GameObject obj` - The game object to check to see if it's interactable.\n  * Returns\n   * `bool` - Is true if the given object is of type `VRTK_InteractableObject`.\n\nThe IsObjectInteractable method is used to check if a given game object is of type `VRTK_InteractableObject` and whether the object is enabled.\n\n### ToggleControllerRigidBody/2\n\n  > `public 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 controller's rigidbody's ability to detect collisions. If it is true then the controller rigidbody will collide with other collidable game objects.\n\n### IsRigidBodyActive/0\n\n  > `public bool IsRigidBodyActive()`\n\n  * Parameters\n   * _none_\n  * Returns\n   * `bool` - Is true if the rigidbody on the controller is currently active and able to affect other scene rigidbodies.\n\nThe IsRigidBodyActive method checks to see if the rigidbody on the controller object is active and can affect other rigidbodies in the scene.\n\n### IsRigidBodyForcedActive/0\n\n  > `public bool IsRigidBodyForcedActive()`\n\n  * Parameters\n   * _none_\n  * Returns\n   * `bool` - Is 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 controller object has been forced into the active state.\n\n### ForceStopTouching/0\n\n  > `public void ForceStopTouching()`\n\n  * Parameters\n   * _none_\n  * Returns\n   * _none_\n\nThe ForceStopTouching method will stop the controller from touching an object even if the controller is physically touching the object still.\n\n### ControllerColliders/0\n\n  > `public 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 controller.\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","type":"basic","title":"VRTK_InteractTouch"}

VRTK_InteractTouch


## Overview The Interact Touch script is usually applied to a Controller and provides a collider to know when the controller is touching something. Colliders are created for the controller and by default the selected controller SDK will have a set of colliders for the given default controller of that SDK. A custom collider can be provided by the Custom Rigidbody Object parameter. ## Inspector Parameters * **Custom Rigidbody Object:** If a custom rigidbody and collider for the rigidbody are required, then a gameobject containing a rigidbody and collider can be passed into this parameter. If this is empty then the rigidbody and collider will be auto generated at runtime to match the SDK default controller. ## Class Events * `ControllerTouchInteractableObject` - Emitted when a valid object is touched. * `ControllerUntouchInteractableObject` - Emitted when a valid object is no longer being touched. ## Unity Events Adding the `VRTK_InteractTouch_UnityEvents` component to `VRTK_InteractTouch` object allows access to `UnityEvents` that will react identically to the Class Events. * `OnControllerTouchInteractableObject` - Emits the ControllerTouchInteractableObject class event. * `OnControllerUntouchInteractableObject` - Emits the ControllerUntouchInteractableObject class event. ## Event Payload * `uint controllerIndex` - The index of the controller doing the interaction. * `GameObject target` - The GameObject of the interactable object that is being interacted with by the controller. ## Class Methods ### ForceTouch/1 > `public void ForceTouch(GameObject obj)` * Parameters * `GameObject obj` - The game object to attempt to force touch. * Returns * _none_ The ForceTouch method will attempt to force the controller to touch the given game object. This is useful if an object that isn't being touched is required to be grabbed or used as the controller doesn't physically have to be touching it to be forced to interact with it. ### GetTouchedObject/0 > `public GameObject GetTouchedObject()` * Parameters * _none_ * Returns * `GameObject` - The game object of what is currently being touched by this controller. The GetTouchedObject method returns the current object being touched by the controller. ### IsObjectInteractable/1 > `public bool IsObjectInteractable(GameObject obj)` * Parameters * `GameObject obj` - The game object to check to see if it's interactable. * Returns * `bool` - Is true if the given object is of type `VRTK_InteractableObject`. The IsObjectInteractable method is used to check if a given game object is of type `VRTK_InteractableObject` and whether the object is enabled. ### ToggleControllerRigidBody/2 > `public 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 controller's rigidbody's ability to detect collisions. If it is true then the controller rigidbody will collide with other collidable game objects. ### IsRigidBodyActive/0 > `public bool IsRigidBodyActive()` * Parameters * _none_ * Returns * `bool` - Is true if the rigidbody on the controller is currently active and able to affect other scene rigidbodies. The IsRigidBodyActive method checks to see if the rigidbody on the controller object is active and can affect other rigidbodies in the scene. ### IsRigidBodyForcedActive/0 > `public bool IsRigidBodyForcedActive()` * Parameters * _none_ * Returns * `bool` - Is 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 controller object has been forced into the active state. ### ForceStopTouching/0 > `public void ForceStopTouching()` * Parameters * _none_ * Returns * _none_ The ForceStopTouching method will stop the controller from touching an object even if the controller is physically touching the object still. ### ControllerColliders/0 > `public 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 controller. ## 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.