{"_id":"5b1f8576c2505d000312548b","category":{"_id":"5b1f8576c2505d000312542a","version":"5b1f8576c2505d00031254db","project":"571fa55ca0acd42000af9545","__v":0,"sync":{"url":"","isSync":false},"reference":false,"createdAt":"2017-01-01T16:45:52.489Z","from_sync":false,"order":7,"slug":"interactions","title":"Interactables"},"project":"571fa55ca0acd42000af9545","user":"571fa519db52d01700f5cf3d","parentDoc":null,"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"},"githubsync":"","__v":0,"updates":[],"next":{"pages":[],"description":""},"createdAt":"2017-01-01T16:46:54.005Z","link_external":false,"link_url":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":1,"body":"## Overview\n\nDetermines if the GameObject can be interacted with.\n\n**Required Components:**\n * `Collider` - A Unity Collider to determine when an interaction has occured. Can be a compound collider set in child GameObjects.\n\n**Optional Components:**\n * `Rigidbody` - A Unity Rigidbody to allow the GameObject to be affected by the Unity Physics System (not required for Climbable Grab Attach Types).\n * `VRTK_BaseGrabAttach` - A Grab Attach mechanic for determining how the Interactable Object is grabbed by the primary interacting object.\n * `VRTK_BaseGrabAction` - A Grab Action mechanic for determining how to manipulate the Interactable Object when grabbed by the secondary interacting object.\n\n**Script Usage:**\n * Place the `VRTK_InteractableObject` script onto the GameObject that is to be interactable.\n * Alternatively, select the GameObject and use the `Window -> VRTK -> Setup Interactable Object` panel to set up quickly.\n * The optional Highlighter used by the Interactable Object will be selected in the following order:\n   * The provided Base Highlighter in the `Object Highlighter` parameter.\n   * If the above is not provided, then the first active Base Highlighter found on the Interactable Object GameObject will be used.\n   * If the above is not found, then a Material Color Swap Highlighter will be created on the Interactable Object GameObject at runtime.\n\n**Script Dependencies:**\n * Interactions\n   * To near touch an Interactable Object the Interact NearTouch script is required on a controller Script Alias GameObject.\n   * To touch an Interactable Object the Interact NearTouch script is required on a controller Script Alias GameObject.\n   * To grab an Interactable Object the Interact Grab script is required on a controller Script Alias GameObject.\n   * To use an Interactable Object the Interact Use script is required on a controller Script Alias GameObject.\n * Highlighting\n   * To highlight an Interactable Object on a given interaction then a valid Interact Object Highlighter script must be associated with the Interactable Object.\n * Appearance\n   * To affect the appearance of an Interactable Object then a valid Interact Object Appearance script must be associated with the Interactable Object.\n\n## Inspector Parameters\n\n * **Disable When Idle:** If this is checked then the Interactable Object component will be disabled when the Interactable Object is not being interacted with.\n * **Allowed Near Touch Controllers:** Determines which controller can initiate a near touch action.\n * **Allowed Touch Controllers:** Determines which controller can initiate a touch action.\n * **Ignored Colliders:** An array of colliders on the GameObject to ignore when being touched.\n * **Is Grabbable:** Determines if the Interactable Object can be grabbed.\n * **Hold Button To Grab:** If this is checked then the grab button on the controller needs to be continually held down to keep grabbing. If this is unchecked the grab button toggles the grab action with one button press to grab and another to release.\n * **Stay Grabbed On Teleport:** If this is checked then the Interactable Object will stay grabbed to the controller when a teleport occurs. If it is unchecked then the Interactable Object will be released when a teleport occurs.\n * **Valid Drop:** Determines in what situation the Interactable Object can be dropped by the controller grab button.\n * **Grab Override Button:** Setting to a button will ensure the override button is used to grab this specific Interactable Object. Setting to `Undefined` will mean the `Grab Button` on the Interact Grab script will grab the object.\n * **Allowed Grab Controllers:** Determines which controller can initiate a grab action.\n * **Grab Attach Mechanic Script:** This determines how the grabbed Interactable Object will be attached to the controller when it is grabbed. If one isn't provided then the first Grab Attach script on the GameObject will be used, if one is not found and the object is grabbable then a Fixed Joint Grab Attach script will be created at runtime.\n * **Secondary Grab Action Script:** The script to utilise when processing the secondary controller action on a secondary grab attempt. If one isn't provided then the first Secondary Controller Grab Action script on the GameObject will be used, if one is not found then no action will be taken on secondary grab.\n * **Is Usable:** Determines if the Interactable Object can be used.\n * **Hold Button To Use:** If this is checked then the use button on the controller needs to be continually held down to keep using. If this is unchecked the the use button toggles the use action with one button press to start using and another to stop using.\n * **Use Only If Grabbed:** If this is checked the Interactable Object can be used only if it is currently being grabbed.\n * **Pointer Activates Use Action:** If this is checked then when a Pointer collides with the Interactable Object it will activate it's use action. If the the `Hold Button To Use` parameter is unchecked then whilst the Pointer is collising with the Interactable Object it will run the `Using` method. If `Hold Button To Use` is unchecked then the `Using` method will be run when the Pointer is deactivated. The Pointer will not emit the `Destination Set` event if it is affecting an Interactable Object with this setting checked as this prevents unwanted teleporting from happening when using an Interactable Object with a pointer.\n * **Use Override Button:** Setting to a button will ensure the override button is used to use this specific Interactable Object. Setting to `Undefined` will mean the `Use Button` on the Interact Use script will use the object.\n * **Allowed Use Controllers:** Determines which controller can initiate a use action.\n\n## Class Variables\n\n * `public enum InteractionType` - The interaction type.\n   * `None` - No interaction is affecting the object.\n   * `NearTouch` - The near touch interaction is affecting the object.\n   * `NearUntouch` - The near untouch interaction stopped affecting the object\n   * `Touch` - The touch interaction is affecting the object.\n   * `Untouch` - The untouch interaction stopped affecting the object\n   * `Grab` - The grab interaction is affecting the object.\n   * `Ungrab` - The ungrab interaction stopped affecting the object\n   * `Use` - The use interaction is affecting the object.\n   * `Unuse` - The unuse interaction stopped affecting the object\n * `public enum AllowedController` - Allowed controller type.\n   * `Both` - Both controllers are allowed to interact.\n   * `LeftOnly` - Only the left controller is allowed to interact.\n   * `RightOnly` - Only the right controller is allowed to interact.\n * `public enum ValidDropTypes` - The types of valid situations that the object can be released from grab.\n   * `NoDrop` - The object cannot be dropped via the controller.\n   * `DropAnywhere` - The object can be dropped anywhere in the scene via the controller.\n   * `DropValidSnapDropZone` - The object can only be dropped when it is hovering over a valid snap drop zone.\n * `public int usingState` - The current using state of the Interactable Object. `0` not being used, `1` being used. Default: `0`\n * `public bool isKinematic` - isKinematic is a pass through to the `isKinematic` getter/setter on the Interactable Object's Rigidbody component.\n\n## Class Events\n\n * `InteractableObjectEnabled` - Emitted when the Interactable Object script is enabled;\n * `InteractableObjectDisabled` - Emitted when the Interactable Object script is disabled;\n * `InteractableObjectNearTouched` - Emitted when another interacting object near touches the current Interactable Object.\n * `InteractableObjectNearUntouched` - Emitted when the other interacting object stops near touching the current Interactable Object.\n * `InteractableObjectTouched` - Emitted when another interacting object touches the current Interactable Object.\n * `InteractableObjectUntouched` - Emitted when the other interacting object stops touching the current Interactable Object.\n * `InteractableObjectGrabbed` - Emitted when another interacting object grabs the current Interactable Object.\n * `InteractableObjectUngrabbed` - Emitted when the other interacting object stops grabbing the current Interactable Object.\n * `InteractableObjectUsed` - Emitted when another interacting object uses the current Interactable Object.\n * `InteractableObjectUnused` - Emitted when the other interacting object stops using the current Interactable Object.\n * `InteractableObjectEnteredSnapDropZone` - Emitted when the Interactable Object enters a Snap Drop Zone.\n * `InteractableObjectExitedSnapDropZone` - Emitted when the Interactable Object exists a Snap Drop Zone.\n * `InteractableObjectSnappedToDropZone` - Emitted when the Interactable Object gets snapped to a Snap Drop Zone.\n * `InteractableObjectUnsnappedFromDropZone` - Emitted when the Interactable Object gets unsnapped from a Snap Drop Zone.\n\n## Unity Events\n\nAdding the `VRTK_InteractableObject_UnityEvents` component to `VRTK_InteractableObject` 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 * `GameObject interactingObject` - The GameObject that is initiating the interaction (e.g. a controller).\n\n## Class Methods\n\n### IsNearTouched/0\n\n  > `public virtual bool IsNearTouched()`\n\n * Parameters\n   * _none_\n * Returns\n   * `bool` - Returns `true` if the Interactable Object is currently being near touched.\n\nThe IsNearTouched method is used to determine if the Interactable Object is currently being near touched.\n\n### IsTouched/0\n\n  > `public virtual bool IsTouched()`\n\n * Parameters\n   * _none_\n * Returns\n   * `bool` - Returns `true` if the Interactable Object is currently being touched.\n\nThe IsTouched method is used to determine if the Interactable Object is currently being touched.\n\n### IsGrabbed/1\n\n  > `public virtual bool IsGrabbed(GameObject grabbedBy = null)`\n\n * Parameters\n   * `GameObject grabbedBy` - An optional GameObject to check if the Interactable Object is grabbed by that specific GameObject. Defaults to `null`\n * Returns\n   * `bool` - Returns `true` if the Interactable Object is currently being grabbed.\n\nThe IsGrabbed method is used to determine if the Interactable Object is currently being grabbed.\n\n### IsUsing/1\n\n  > `public virtual bool IsUsing(GameObject usedBy = null)`\n\n * Parameters\n   * `GameObject usedBy` - An optional GameObject to check if the Interactable Object is used by that specific GameObject. Defaults to `null`\n * Returns\n   * `bool` - Returns `true` if the Interactable Object is currently being used.\n\nThe IsUsing method is used to determine if the Interactable Object is currently being used.\n\n### StartNearTouching/1\n\n  > `public virtual void StartNearTouching(VRTK_InteractNearTouch currentNearTouchingObject = null)`\n\n * Parameters\n   * `VRTK_InteractNearTouch currentNearTouchingObject` - The interacting object that is currently nearly touching this Interactable Object.\n * Returns\n   * _none_\n\nThe StartNearTouching method is called automatically when the Interactable Object is initially nearly touched.\n\n### StopNearTouching/1\n\n  > `public virtual void StopNearTouching(VRTK_InteractNearTouch previousNearTouchingObject = null)`\n\n * Parameters\n   * `VRTK_InteractNearTouch previousNearTouchingObject` - The interacting object that was previously nearly touching this Interactable Object.\n * Returns\n   * _none_\n\nThe StopNearTouching method is called automatically when the Interactable Object has stopped being nearly touched.\n\n### StartTouching/1\n\n  > `public virtual void StartTouching(VRTK_InteractTouch currentTouchingObject = null)`\n\n * Parameters\n   * `VRTK_InteractTouch currentTouchingObject` - The interacting object that is currently touching this Interactable Object.\n * Returns\n   * _none_\n\nThe StartTouching method is called automatically when the Interactable Object is touched initially.\n\n### StopTouching/1\n\n  > `public virtual void StopTouching(VRTK_InteractTouch previousTouchingObject = null)`\n\n * Parameters\n   * `VRTK_InteractTouch previousTouchingObject` - The interacting object that was previously touching this Interactable Object.\n * Returns\n   * _none_\n\nThe StopTouching method is called automatically when the Interactable Object has stopped being touched.\n\n### Grabbed/1\n\n  > `public virtual void Grabbed(VRTK_InteractGrab currentGrabbingObject = null)`\n\n * Parameters\n   * `VRTK_InteractGrab currentGrabbingObject` - The interacting object that is currently grabbing this Interactable Object.\n * Returns\n   * _none_\n\nThe Grabbed method is called automatically when the Interactable Object is grabbed initially.\n\n### Ungrabbed/1\n\n  > `public virtual void Ungrabbed(VRTK_InteractGrab previousGrabbingObject = null)`\n\n * Parameters\n   * `VRTK_InteractGrab previousGrabbingObject` - The interacting object that was previously grabbing this Interactable Object.\n * Returns\n   * _none_\n\nThe Ungrabbed method is called automatically when the Interactable Object has stopped being grabbed.\n\n### StartUsing/1\n\n  > `public virtual void StartUsing(VRTK_InteractUse currentUsingObject = null)`\n\n * Parameters\n   * `VRTK_InteractUse currentUsingObject` - The interacting object that is currently using this Interactable Object.\n * Returns\n   * _none_\n\nThe StartUsing method is called automatically when the Interactable Object is used initially.\n\n### StopUsing/2\n\n  > `public virtual void StopUsing(VRTK_InteractUse previousUsingObject = null, bool resetUsingObjectState = true)`\n\n * Parameters\n   * `VRTK_InteractUse previousUsingObject` - The interacting object that was previously using this Interactable Object.\n   * `bool resetUsingObjectState` - Resets the using object state to reset it's using action.\n * Returns\n   * _none_\n\nThe StopUsing method is called automatically when the Interactable Object has stopped being used.\n\n### PauseCollisions/1\n\n  > `public virtual void PauseCollisions(float delay)`\n\n * Parameters\n   * `float delay` - The time in seconds to pause the collisions for.\n * Returns\n   * _none_\n\nThe PauseCollisions method temporarily pauses all collisions on the Interactable Object at grab time by removing the Interactable Object's Rigidbody's ability to detect collisions.\n\n### ZeroVelocity/0\n\n  > `public virtual void ZeroVelocity()`\n\n * Parameters\n   * _none_\n * Returns\n   * _none_\n\nThe ZeroVelocity method resets the velocity and angular velocity to zero on the Rigidbody attached to the Interactable Object.\n\n### SaveCurrentState/0\n\n  > `public virtual void SaveCurrentState()`\n\n * Parameters\n   * _none_\n * Returns\n   * _none_\n\nThe SaveCurrentState method stores the existing Interactable Object parent and the Rigidbody kinematic setting.\n\n### GetPreviousState/3\n\n  > `public virtual void GetPreviousState(out Transform previousParent, out bool previousKinematic, out bool previousGrabbable)`\n\n * Parameters\n   * `out Transform previousParent` - Out param for the previous parent\n   * `out bool previousKinematic` - Out param for the previous Kinematic state\n   * `out bool previousGrabbable` - Out param for the previous Grabbable State\n * Returns\n   * _none_\n\nReturns the previous state of the Interactable Object\n\n### OverridePreviousState/3\n\n  > `public virtual void OverridePreviousState(Transform previousParent, bool previousKinematic, bool previousGrabbable)`\n\n * Parameters\n   * `Transform previousParent` - value of the previous parent\n   * `bool previousKinematic` - value of the previous Kinematic state\n   * `bool previousGrabbable` - value of the previous Grabbable State\n * Returns\n   * _none_\n\nOverrides the previous state of the Interactable Object\n\n### GetNearTouchingObjects/0\n\n  > `public virtual List<GameObject> GetNearTouchingObjects()`\n\n * Parameters\n   * _none_\n * Returns\n   * `List<GameObject>` - A list of GameObject of that are currently nearly touching the current Interactable Object.\n\nThe GetNearTouchingObjects method is used to return the collecetion of valid GameObjects that are currently nearly touching this Interactable Object.\n\n### GetTouchingObjects/0\n\n  > `public virtual List<GameObject> GetTouchingObjects()`\n\n * Parameters\n   * _none_\n * Returns\n   * `List<GameObject>` - A list of GameObject of that are currently touching the current Interactable Object.\n\nThe GetTouchingObjects method is used to return the collecetion of valid GameObjects that are currently touching this Interactable Object.\n\n### GetGrabbingObject/0\n\n  > `public virtual GameObject GetGrabbingObject()`\n\n * Parameters\n   * _none_\n * Returns\n   * `GameObject` - The GameObject of what is grabbing the current Interactable Object.\n\nThe GetGrabbingObject method is used to return the GameObject that is currently grabbing this Interactable Object.\n\n### GetSecondaryGrabbingObject/0\n\n  > `public virtual GameObject GetSecondaryGrabbingObject()`\n\n * Parameters\n   * _none_\n * Returns\n   * `GameObject` - The GameObject of the secondary influencing object of the current grabbed Interactable Object.\n\nThe GetSecondaryGrabbingObject method is used to return the GameObject that is currently being used to influence this Interactable Object whilst it is being grabbed by a secondary influencing.\n\n### GetUsingObject/0\n\n  > `public virtual GameObject GetUsingObject()`\n\n * Parameters\n   * _none_\n * Returns\n   * `GameObject` - The GameObject of what is using the current Interactable Object.\n\nThe GetUsingObject method is used to return the GameObject that is currently using this Interactable Object.\n\n### GetUsingScript/0\n\n  > `public virtual VRTK_InteractUse GetUsingScript()`\n\n * Parameters\n   * _none_\n * Returns\n   * `VRTK_InteractUse` - The Interact Use script of the interacting object that is using the current Interactable Object.\n\nThe GetUsingScript method is used to return the Interact Use component that is currently using this Interactable Object.\n\n### IsValidInteractableController/2\n\n  > `public virtual bool IsValidInteractableController(GameObject actualController, AllowedController controllerCheck)`\n\n * Parameters\n   * `GameObject actualController` - The GameObject of the controller that is being checked.\n   * `AllowedController controllerCheck` - The value of which controller is allowed to interact with this object.\n * Returns\n   * `bool` - Returns `true` if the interacting controller is allowed to grab the Interactable Object.\n\nThe IsValidInteractableController method is used to check to see if a controller is allowed to perform an interaction with this Interactable Object as sometimes controllers are prohibited from grabbing or using an Interactable Object depedning on the use case.\n\n### ForceStopInteracting/0\n\n  > `public virtual void ForceStopInteracting()`\n\n * Parameters\n   * _none_\n * Returns\n   * _none_\n\nThe ForceStopInteracting method forces the Interactable Object to no longer be interacted with and will cause an interacting object to drop the Interactable Object and stop touching it.\n\n### ForceStopSecondaryGrabInteraction/0\n\n  > `public virtual void ForceStopSecondaryGrabInteraction()`\n\n * Parameters\n   * _none_\n * Returns\n   * _none_\n\nThe ForceStopSecondaryGrabInteraction method forces the Interactable Object to no longer be influenced by the second controller grabbing it.\n\n### RegisterTeleporters/0\n\n  > `public virtual void RegisterTeleporters()`\n\n * Parameters\n   * _none_\n * Returns\n   * _none_\n\nThe RegisterTeleporters method is used to find all GameObjects that have a teleporter script and register the Interactable Object on the `OnTeleported` event.\n\n### UnregisterTeleporters/0\n\n  > `public virtual void UnregisterTeleporters()`\n\n * Parameters\n   * _none_\n * Returns\n   * _none_\n\nThe UnregisterTeleporters method is used to unregister all teleporter events that are active on this Interactable Object.\n\n### StoreLocalScale/0\n\n  > `public virtual void StoreLocalScale()`\n\n * Parameters\n   * _none_\n * Returns\n   * _none_\n\nthe StoreLocalScale method saves the current transform local scale values.\n\n### ToggleSnapDropZone/2\n\n  > `public virtual void ToggleSnapDropZone(VRTK_SnapDropZone snapDropZone, bool state)`\n\n * Parameters\n   * `VRTK_SnapDropZone snapDropZone` - The Snap Drop Zone object that is being interacted with.\n   * `bool state` - The state of whether the Interactable Object is fixed in or removed from the Snap Drop Zone. `true` denotes the Interactable Object is snapped to the Snap Drop Zone and `false` denotes it has been removed from the Snap Drop Zone.\n * Returns\n   * _none_\n\nThe ToggleSnapDropZone method is used to set the state of whether the Interactable Object is in a Snap Drop Zone or not.\n\n### IsInSnapDropZone/0\n\n  > `public virtual bool IsInSnapDropZone()`\n\n * Parameters\n   * _none_\n * Returns\n   * `bool` - Returns `true` if the Interactable Object is currently snapped in a Snap Drop Zone, returns `false` if it is not.\n\nThe IsInSnapDropZone method determines whether the Interactable Object is currently snapped to a Snap Drop Zone.\n\n### SetSnapDropZoneHover/2\n\n  > `public virtual void SetSnapDropZoneHover(VRTK_SnapDropZone snapDropZone, bool state)`\n\n * Parameters\n   * `VRTK_SnapDropZone snapDropZone` - The Snap Drop Zone that is being interacted with.\n   * `bool state` - The state of whether the Interactable Object is being hovered or not.\n * Returns\n   * _none_\n\nThe SetSnapDropZoneHover method sets whether the Interactable Object is currently being hovered over a valid Snap Drop Zone.\n\n### GetStoredSnapDropZone/0\n\n  > `public virtual VRTK_SnapDropZone GetStoredSnapDropZone()`\n\n * Parameters\n   * _none_\n * Returns\n   * `VRTK_SnapDropZone` - The SnapDropZone that the Interactable Object is currently snapped to.\n\nThe GetStoredSnapDropZone method returns the Snap Drop Zone that the Interactable Object is currently snapped to.\n\n### IsHoveredOverSnapDropZone/0\n\n  > `public virtual bool IsHoveredOverSnapDropZone()`\n\n * Parameters\n   * _none_\n * Returns\n   * `bool` - Returns `true` if the Interactable Object is currently hovering over a Snap Drop Zone.\n\nThe IsHoveredOverSnapDropZone method returns whether the Interactable Object is currently hovering over a Snap Drop Zone.\n\n### IsDroppable/0\n\n  > `public virtual bool IsDroppable()`\n\n * Parameters\n   * _none_\n * Returns\n   * `bool` - Returns `true` if the Interactable Object can currently be dropped, returns `false` if it is not currently possible to drop.\n\nThe IsDroppable method returns whether the Interactable Object can be dropped or not in it's current situation.\n\n### IsSwappable/0\n\n  > `public virtual bool IsSwappable()`\n\n * Parameters\n   * _none_\n * Returns\n   * `bool` - Returns `true` if the Interactable Object can be grabbed by a secondary interacting object whilst already being grabbed and the Interactable Object will swap controllers. Returns `false` if the Interactable Object cannot be swapped.\n\nThe IsSwappable method returns whether the Interactable Object can be grabbed with one interacting object and then swapped to another interacting object by grabbing with the secondary grab action.\n\n### PerformSecondaryAction/0\n\n  > `public virtual bool PerformSecondaryAction()`\n\n * Parameters\n   * _none_\n * Returns\n   * `bool` - Returns `true` if the Interactable Object has a Secondary Grab Action, returns `false` if it has no Secondary Grab Action or is swappable.\n\nThe PerformSecondaryAction method returns whether the Interactable Object has a Secondary Grab Action that can be performed when grabbing the object with a secondary interacting object.\n\n### ResetIgnoredColliders/0\n\n  > `public virtual void ResetIgnoredColliders()`\n\n * Parameters\n   * _none_\n * Returns\n   * _none_\n\nThe ResetIgnoredColliders method is used to clear any stored ignored colliders in case the `Ignored Colliders` array parameter is changed at runtime. This needs to be called manually if changes are made at runtime.\n\n### SubscribeToInteractionEvent/2\n\n  > `public virtual void SubscribeToInteractionEvent(InteractionType givenType, InteractableObjectEventHandler methodCallback)`\n\n * Parameters\n   * `InteractionType givenType` - The Interaction Type to register the events for.\n   * `InteractableObjectEventHandler methodCallback` - The method to execute when the Interaction Type is initiated.\n * Returns\n   * _none_\n\nThe SubscribeToInteractionEvent method subscribes a given method callback for the given Interaction Type.\n\n### UnsubscribeFromInteractionEvent/2\n\n  > `public virtual void UnsubscribeFromInteractionEvent(InteractionType givenType, InteractableObjectEventHandler methodCallback)`\n\n * Parameters\n   * `InteractionType givenType` - The Interaction Type that the previous event subscription was under.\n   * `InteractableObjectEventHandler methodCallback` - The method that was being executed when the Interaction Type was initiated.\n * Returns\n   * _none_\n\nThe UnsubscribeFromInteractionEvent method unsubscribes a previous event subscription for the given Interaction Type.\n\n### GetPrimaryAttachPoint/0\n\n  > `public virtual Transform GetPrimaryAttachPoint()`\n\n * Parameters\n   * _none_\n * Returns\n   * `Transform` - A Transform that denotes where the primary grabbing object is grabbing the Interactable Object at.\n\nThe GetPrimaryAttachPoint returns the Transform that determines where the primary grabbing object is grabbing the Interactable Object at.\n\n### GetSecondaryAttachPoint/0\n\n  > `public virtual Transform GetSecondaryAttachPoint()`\n\n * Parameters\n   * _none_\n * Returns\n   * `Transform` - A Transform that denotes where the secondary grabbing object is grabbing the Interactable Object at.\n\nThe GetSecondaryAttachPoint returns the Transform that determines where the secondary grabbing object is grabbing the Interactable Object at.\n\n## Example\n\n`VRTK/Examples/005_Controller_BasicObjectGrabbing` uses the `VRTK_InteractTouch` and `VRTK_InteractGrab` scripts on the controllers to show how an interactable object can be grabbed and snapped to the controller and thrown around the game world.\n\n`VRTK/Examples/013_Controller_UsingAndGrabbingMultipleObjects` shows multiple objects that can be grabbed by holding the buttons or grabbed by toggling the button click and also has objects that can have their Using state toggled to show how multiple items can be turned on at the same time.","excerpt":"","slug":"vrtk_interactableobject","type":"basic","title":"VRTK_InteractableObject"}

VRTK_InteractableObject


## Overview Determines if the GameObject can be interacted with. **Required Components:** * `Collider` - A Unity Collider to determine when an interaction has occured. Can be a compound collider set in child GameObjects. **Optional Components:** * `Rigidbody` - A Unity Rigidbody to allow the GameObject to be affected by the Unity Physics System (not required for Climbable Grab Attach Types). * `VRTK_BaseGrabAttach` - A Grab Attach mechanic for determining how the Interactable Object is grabbed by the primary interacting object. * `VRTK_BaseGrabAction` - A Grab Action mechanic for determining how to manipulate the Interactable Object when grabbed by the secondary interacting object. **Script Usage:** * Place the `VRTK_InteractableObject` script onto the GameObject that is to be interactable. * Alternatively, select the GameObject and use the `Window -> VRTK -> Setup Interactable Object` panel to set up quickly. * The optional Highlighter used by the Interactable Object will be selected in the following order: * The provided Base Highlighter in the `Object Highlighter` parameter. * If the above is not provided, then the first active Base Highlighter found on the Interactable Object GameObject will be used. * If the above is not found, then a Material Color Swap Highlighter will be created on the Interactable Object GameObject at runtime. **Script Dependencies:** * Interactions * To near touch an Interactable Object the Interact NearTouch script is required on a controller Script Alias GameObject. * To touch an Interactable Object the Interact NearTouch script is required on a controller Script Alias GameObject. * To grab an Interactable Object the Interact Grab script is required on a controller Script Alias GameObject. * To use an Interactable Object the Interact Use script is required on a controller Script Alias GameObject. * Highlighting * To highlight an Interactable Object on a given interaction then a valid Interact Object Highlighter script must be associated with the Interactable Object. * Appearance * To affect the appearance of an Interactable Object then a valid Interact Object Appearance script must be associated with the Interactable Object. ## Inspector Parameters * **Disable When Idle:** If this is checked then the Interactable Object component will be disabled when the Interactable Object is not being interacted with. * **Allowed Near Touch Controllers:** Determines which controller can initiate a near touch action. * **Allowed Touch Controllers:** Determines which controller can initiate a touch action. * **Ignored Colliders:** An array of colliders on the GameObject to ignore when being touched. * **Is Grabbable:** Determines if the Interactable Object can be grabbed. * **Hold Button To Grab:** If this is checked then the grab button on the controller needs to be continually held down to keep grabbing. If this is unchecked the grab button toggles the grab action with one button press to grab and another to release. * **Stay Grabbed On Teleport:** If this is checked then the Interactable Object will stay grabbed to the controller when a teleport occurs. If it is unchecked then the Interactable Object will be released when a teleport occurs. * **Valid Drop:** Determines in what situation the Interactable Object can be dropped by the controller grab button. * **Grab Override Button:** Setting to a button will ensure the override button is used to grab this specific Interactable Object. Setting to `Undefined` will mean the `Grab Button` on the Interact Grab script will grab the object. * **Allowed Grab Controllers:** Determines which controller can initiate a grab action. * **Grab Attach Mechanic Script:** This determines how the grabbed Interactable Object will be attached to the controller when it is grabbed. If one isn't provided then the first Grab Attach script on the GameObject will be used, if one is not found and the object is grabbable then a Fixed Joint Grab Attach script will be created at runtime. * **Secondary Grab Action Script:** The script to utilise when processing the secondary controller action on a secondary grab attempt. If one isn't provided then the first Secondary Controller Grab Action script on the GameObject will be used, if one is not found then no action will be taken on secondary grab. * **Is Usable:** Determines if the Interactable Object can be used. * **Hold Button To Use:** If this is checked then the use button on the controller needs to be continually held down to keep using. If this is unchecked the the use button toggles the use action with one button press to start using and another to stop using. * **Use Only If Grabbed:** If this is checked the Interactable Object can be used only if it is currently being grabbed. * **Pointer Activates Use Action:** If this is checked then when a Pointer collides with the Interactable Object it will activate it's use action. If the the `Hold Button To Use` parameter is unchecked then whilst the Pointer is collising with the Interactable Object it will run the `Using` method. If `Hold Button To Use` is unchecked then the `Using` method will be run when the Pointer is deactivated. The Pointer will not emit the `Destination Set` event if it is affecting an Interactable Object with this setting checked as this prevents unwanted teleporting from happening when using an Interactable Object with a pointer. * **Use Override Button:** Setting to a button will ensure the override button is used to use this specific Interactable Object. Setting to `Undefined` will mean the `Use Button` on the Interact Use script will use the object. * **Allowed Use Controllers:** Determines which controller can initiate a use action. ## Class Variables * `public enum InteractionType` - The interaction type. * `None` - No interaction is affecting the object. * `NearTouch` - The near touch interaction is affecting the object. * `NearUntouch` - The near untouch interaction stopped affecting the object * `Touch` - The touch interaction is affecting the object. * `Untouch` - The untouch interaction stopped affecting the object * `Grab` - The grab interaction is affecting the object. * `Ungrab` - The ungrab interaction stopped affecting the object * `Use` - The use interaction is affecting the object. * `Unuse` - The unuse interaction stopped affecting the object * `public enum AllowedController` - Allowed controller type. * `Both` - Both controllers are allowed to interact. * `LeftOnly` - Only the left controller is allowed to interact. * `RightOnly` - Only the right controller is allowed to interact. * `public enum ValidDropTypes` - The types of valid situations that the object can be released from grab. * `NoDrop` - The object cannot be dropped via the controller. * `DropAnywhere` - The object can be dropped anywhere in the scene via the controller. * `DropValidSnapDropZone` - The object can only be dropped when it is hovering over a valid snap drop zone. * `public int usingState` - The current using state of the Interactable Object. `0` not being used, `1` being used. Default: `0` * `public bool isKinematic` - isKinematic is a pass through to the `isKinematic` getter/setter on the Interactable Object's Rigidbody component. ## Class Events * `InteractableObjectEnabled` - Emitted when the Interactable Object script is enabled; * `InteractableObjectDisabled` - Emitted when the Interactable Object script is disabled; * `InteractableObjectNearTouched` - Emitted when another interacting object near touches the current Interactable Object. * `InteractableObjectNearUntouched` - Emitted when the other interacting object stops near touching the current Interactable Object. * `InteractableObjectTouched` - Emitted when another interacting object touches the current Interactable Object. * `InteractableObjectUntouched` - Emitted when the other interacting object stops touching the current Interactable Object. * `InteractableObjectGrabbed` - Emitted when another interacting object grabs the current Interactable Object. * `InteractableObjectUngrabbed` - Emitted when the other interacting object stops grabbing the current Interactable Object. * `InteractableObjectUsed` - Emitted when another interacting object uses the current Interactable Object. * `InteractableObjectUnused` - Emitted when the other interacting object stops using the current Interactable Object. * `InteractableObjectEnteredSnapDropZone` - Emitted when the Interactable Object enters a Snap Drop Zone. * `InteractableObjectExitedSnapDropZone` - Emitted when the Interactable Object exists a Snap Drop Zone. * `InteractableObjectSnappedToDropZone` - Emitted when the Interactable Object gets snapped to a Snap Drop Zone. * `InteractableObjectUnsnappedFromDropZone` - Emitted when the Interactable Object gets unsnapped from a Snap Drop Zone. ## Unity Events Adding the `VRTK_InteractableObject_UnityEvents` component to `VRTK_InteractableObject` 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 * `GameObject interactingObject` - The GameObject that is initiating the interaction (e.g. a controller). ## Class Methods ### IsNearTouched/0 > `public virtual bool IsNearTouched()` * Parameters * _none_ * Returns * `bool` - Returns `true` if the Interactable Object is currently being near touched. The IsNearTouched method is used to determine if the Interactable Object is currently being near touched. ### IsTouched/0 > `public virtual bool IsTouched()` * Parameters * _none_ * Returns * `bool` - Returns `true` if the Interactable Object is currently being touched. The IsTouched method is used to determine if the Interactable Object is currently being touched. ### IsGrabbed/1 > `public virtual bool IsGrabbed(GameObject grabbedBy = null)` * Parameters * `GameObject grabbedBy` - An optional GameObject to check if the Interactable Object is grabbed by that specific GameObject. Defaults to `null` * Returns * `bool` - Returns `true` if the Interactable Object is currently being grabbed. The IsGrabbed method is used to determine if the Interactable Object is currently being grabbed. ### IsUsing/1 > `public virtual bool IsUsing(GameObject usedBy = null)` * Parameters * `GameObject usedBy` - An optional GameObject to check if the Interactable Object is used by that specific GameObject. Defaults to `null` * Returns * `bool` - Returns `true` if the Interactable Object is currently being used. The IsUsing method is used to determine if the Interactable Object is currently being used. ### StartNearTouching/1 > `public virtual void StartNearTouching(VRTK_InteractNearTouch currentNearTouchingObject = null)` * Parameters * `VRTK_InteractNearTouch currentNearTouchingObject` - The interacting object that is currently nearly touching this Interactable Object. * Returns * _none_ The StartNearTouching method is called automatically when the Interactable Object is initially nearly touched. ### StopNearTouching/1 > `public virtual void StopNearTouching(VRTK_InteractNearTouch previousNearTouchingObject = null)` * Parameters * `VRTK_InteractNearTouch previousNearTouchingObject` - The interacting object that was previously nearly touching this Interactable Object. * Returns * _none_ The StopNearTouching method is called automatically when the Interactable Object has stopped being nearly touched. ### StartTouching/1 > `public virtual void StartTouching(VRTK_InteractTouch currentTouchingObject = null)` * Parameters * `VRTK_InteractTouch currentTouchingObject` - The interacting object that is currently touching this Interactable Object. * Returns * _none_ The StartTouching method is called automatically when the Interactable Object is touched initially. ### StopTouching/1 > `public virtual void StopTouching(VRTK_InteractTouch previousTouchingObject = null)` * Parameters * `VRTK_InteractTouch previousTouchingObject` - The interacting object that was previously touching this Interactable Object. * Returns * _none_ The StopTouching method is called automatically when the Interactable Object has stopped being touched. ### Grabbed/1 > `public virtual void Grabbed(VRTK_InteractGrab currentGrabbingObject = null)` * Parameters * `VRTK_InteractGrab currentGrabbingObject` - The interacting object that is currently grabbing this Interactable Object. * Returns * _none_ The Grabbed method is called automatically when the Interactable Object is grabbed initially. ### Ungrabbed/1 > `public virtual void Ungrabbed(VRTK_InteractGrab previousGrabbingObject = null)` * Parameters * `VRTK_InteractGrab previousGrabbingObject` - The interacting object that was previously grabbing this Interactable Object. * Returns * _none_ The Ungrabbed method is called automatically when the Interactable Object has stopped being grabbed. ### StartUsing/1 > `public virtual void StartUsing(VRTK_InteractUse currentUsingObject = null)` * Parameters * `VRTK_InteractUse currentUsingObject` - The interacting object that is currently using this Interactable Object. * Returns * _none_ The StartUsing method is called automatically when the Interactable Object is used initially. ### StopUsing/2 > `public virtual void StopUsing(VRTK_InteractUse previousUsingObject = null, bool resetUsingObjectState = true)` * Parameters * `VRTK_InteractUse previousUsingObject` - The interacting object that was previously using this Interactable Object. * `bool resetUsingObjectState` - Resets the using object state to reset it's using action. * Returns * _none_ The StopUsing method is called automatically when the Interactable Object has stopped being used. ### PauseCollisions/1 > `public virtual void PauseCollisions(float delay)` * Parameters * `float delay` - The time in seconds to pause the collisions for. * Returns * _none_ The PauseCollisions method temporarily pauses all collisions on the Interactable Object at grab time by removing the Interactable Object's Rigidbody's ability to detect collisions. ### ZeroVelocity/0 > `public virtual void ZeroVelocity()` * Parameters * _none_ * Returns * _none_ The ZeroVelocity method resets the velocity and angular velocity to zero on the Rigidbody attached to the Interactable Object. ### SaveCurrentState/0 > `public virtual void SaveCurrentState()` * Parameters * _none_ * Returns * _none_ The SaveCurrentState method stores the existing Interactable Object parent and the Rigidbody kinematic setting. ### GetPreviousState/3 > `public virtual void GetPreviousState(out Transform previousParent, out bool previousKinematic, out bool previousGrabbable)` * Parameters * `out Transform previousParent` - Out param for the previous parent * `out bool previousKinematic` - Out param for the previous Kinematic state * `out bool previousGrabbable` - Out param for the previous Grabbable State * Returns * _none_ Returns the previous state of the Interactable Object ### OverridePreviousState/3 > `public virtual void OverridePreviousState(Transform previousParent, bool previousKinematic, bool previousGrabbable)` * Parameters * `Transform previousParent` - value of the previous parent * `bool previousKinematic` - value of the previous Kinematic state * `bool previousGrabbable` - value of the previous Grabbable State * Returns * _none_ Overrides the previous state of the Interactable Object ### GetNearTouchingObjects/0 > `public virtual List<GameObject> GetNearTouchingObjects()` * Parameters * _none_ * Returns * `List<GameObject>` - A list of GameObject of that are currently nearly touching the current Interactable Object. The GetNearTouchingObjects method is used to return the collecetion of valid GameObjects that are currently nearly touching this Interactable Object. ### GetTouchingObjects/0 > `public virtual List<GameObject> GetTouchingObjects()` * Parameters * _none_ * Returns * `List<GameObject>` - A list of GameObject of that are currently touching the current Interactable Object. The GetTouchingObjects method is used to return the collecetion of valid GameObjects that are currently touching this Interactable Object. ### GetGrabbingObject/0 > `public virtual GameObject GetGrabbingObject()` * Parameters * _none_ * Returns * `GameObject` - The GameObject of what is grabbing the current Interactable Object. The GetGrabbingObject method is used to return the GameObject that is currently grabbing this Interactable Object. ### GetSecondaryGrabbingObject/0 > `public virtual GameObject GetSecondaryGrabbingObject()` * Parameters * _none_ * Returns * `GameObject` - The GameObject of the secondary influencing object of the current grabbed Interactable Object. The GetSecondaryGrabbingObject method is used to return the GameObject that is currently being used to influence this Interactable Object whilst it is being grabbed by a secondary influencing. ### GetUsingObject/0 > `public virtual GameObject GetUsingObject()` * Parameters * _none_ * Returns * `GameObject` - The GameObject of what is using the current Interactable Object. The GetUsingObject method is used to return the GameObject that is currently using this Interactable Object. ### GetUsingScript/0 > `public virtual VRTK_InteractUse GetUsingScript()` * Parameters * _none_ * Returns * `VRTK_InteractUse` - The Interact Use script of the interacting object that is using the current Interactable Object. The GetUsingScript method is used to return the Interact Use component that is currently using this Interactable Object. ### IsValidInteractableController/2 > `public virtual bool IsValidInteractableController(GameObject actualController, AllowedController controllerCheck)` * Parameters * `GameObject actualController` - The GameObject of the controller that is being checked. * `AllowedController controllerCheck` - The value of which controller is allowed to interact with this object. * Returns * `bool` - Returns `true` if the interacting controller is allowed to grab the Interactable Object. The IsValidInteractableController method is used to check to see if a controller is allowed to perform an interaction with this Interactable Object as sometimes controllers are prohibited from grabbing or using an Interactable Object depedning on the use case. ### ForceStopInteracting/0 > `public virtual void ForceStopInteracting()` * Parameters * _none_ * Returns * _none_ The ForceStopInteracting method forces the Interactable Object to no longer be interacted with and will cause an interacting object to drop the Interactable Object and stop touching it. ### ForceStopSecondaryGrabInteraction/0 > `public virtual void ForceStopSecondaryGrabInteraction()` * Parameters * _none_ * Returns * _none_ The ForceStopSecondaryGrabInteraction method forces the Interactable Object to no longer be influenced by the second controller grabbing it. ### RegisterTeleporters/0 > `public virtual void RegisterTeleporters()` * Parameters * _none_ * Returns * _none_ The RegisterTeleporters method is used to find all GameObjects that have a teleporter script and register the Interactable Object on the `OnTeleported` event. ### UnregisterTeleporters/0 > `public virtual void UnregisterTeleporters()` * Parameters * _none_ * Returns * _none_ The UnregisterTeleporters method is used to unregister all teleporter events that are active on this Interactable Object. ### StoreLocalScale/0 > `public virtual void StoreLocalScale()` * Parameters * _none_ * Returns * _none_ the StoreLocalScale method saves the current transform local scale values. ### ToggleSnapDropZone/2 > `public virtual void ToggleSnapDropZone(VRTK_SnapDropZone snapDropZone, bool state)` * Parameters * `VRTK_SnapDropZone snapDropZone` - The Snap Drop Zone object that is being interacted with. * `bool state` - The state of whether the Interactable Object is fixed in or removed from the Snap Drop Zone. `true` denotes the Interactable Object is snapped to the Snap Drop Zone and `false` denotes it has been removed from the Snap Drop Zone. * Returns * _none_ The ToggleSnapDropZone method is used to set the state of whether the Interactable Object is in a Snap Drop Zone or not. ### IsInSnapDropZone/0 > `public virtual bool IsInSnapDropZone()` * Parameters * _none_ * Returns * `bool` - Returns `true` if the Interactable Object is currently snapped in a Snap Drop Zone, returns `false` if it is not. The IsInSnapDropZone method determines whether the Interactable Object is currently snapped to a Snap Drop Zone. ### SetSnapDropZoneHover/2 > `public virtual void SetSnapDropZoneHover(VRTK_SnapDropZone snapDropZone, bool state)` * Parameters * `VRTK_SnapDropZone snapDropZone` - The Snap Drop Zone that is being interacted with. * `bool state` - The state of whether the Interactable Object is being hovered or not. * Returns * _none_ The SetSnapDropZoneHover method sets whether the Interactable Object is currently being hovered over a valid Snap Drop Zone. ### GetStoredSnapDropZone/0 > `public virtual VRTK_SnapDropZone GetStoredSnapDropZone()` * Parameters * _none_ * Returns * `VRTK_SnapDropZone` - The SnapDropZone that the Interactable Object is currently snapped to. The GetStoredSnapDropZone method returns the Snap Drop Zone that the Interactable Object is currently snapped to. ### IsHoveredOverSnapDropZone/0 > `public virtual bool IsHoveredOverSnapDropZone()` * Parameters * _none_ * Returns * `bool` - Returns `true` if the Interactable Object is currently hovering over a Snap Drop Zone. The IsHoveredOverSnapDropZone method returns whether the Interactable Object is currently hovering over a Snap Drop Zone. ### IsDroppable/0 > `public virtual bool IsDroppable()` * Parameters * _none_ * Returns * `bool` - Returns `true` if the Interactable Object can currently be dropped, returns `false` if it is not currently possible to drop. The IsDroppable method returns whether the Interactable Object can be dropped or not in it's current situation. ### IsSwappable/0 > `public virtual bool IsSwappable()` * Parameters * _none_ * Returns * `bool` - Returns `true` if the Interactable Object can be grabbed by a secondary interacting object whilst already being grabbed and the Interactable Object will swap controllers. Returns `false` if the Interactable Object cannot be swapped. The IsSwappable method returns whether the Interactable Object can be grabbed with one interacting object and then swapped to another interacting object by grabbing with the secondary grab action. ### PerformSecondaryAction/0 > `public virtual bool PerformSecondaryAction()` * Parameters * _none_ * Returns * `bool` - Returns `true` if the Interactable Object has a Secondary Grab Action, returns `false` if it has no Secondary Grab Action or is swappable. The PerformSecondaryAction method returns whether the Interactable Object has a Secondary Grab Action that can be performed when grabbing the object with a secondary interacting object. ### ResetIgnoredColliders/0 > `public virtual void ResetIgnoredColliders()` * Parameters * _none_ * Returns * _none_ The ResetIgnoredColliders method is used to clear any stored ignored colliders in case the `Ignored Colliders` array parameter is changed at runtime. This needs to be called manually if changes are made at runtime. ### SubscribeToInteractionEvent/2 > `public virtual void SubscribeToInteractionEvent(InteractionType givenType, InteractableObjectEventHandler methodCallback)` * Parameters * `InteractionType givenType` - The Interaction Type to register the events for. * `InteractableObjectEventHandler methodCallback` - The method to execute when the Interaction Type is initiated. * Returns * _none_ The SubscribeToInteractionEvent method subscribes a given method callback for the given Interaction Type. ### UnsubscribeFromInteractionEvent/2 > `public virtual void UnsubscribeFromInteractionEvent(InteractionType givenType, InteractableObjectEventHandler methodCallback)` * Parameters * `InteractionType givenType` - The Interaction Type that the previous event subscription was under. * `InteractableObjectEventHandler methodCallback` - The method that was being executed when the Interaction Type was initiated. * Returns * _none_ The UnsubscribeFromInteractionEvent method unsubscribes a previous event subscription for the given Interaction Type. ### GetPrimaryAttachPoint/0 > `public virtual Transform GetPrimaryAttachPoint()` * Parameters * _none_ * Returns * `Transform` - A Transform that denotes where the primary grabbing object is grabbing the Interactable Object at. The GetPrimaryAttachPoint returns the Transform that determines where the primary grabbing object is grabbing the Interactable Object at. ### GetSecondaryAttachPoint/0 > `public virtual Transform GetSecondaryAttachPoint()` * Parameters * _none_ * Returns * `Transform` - A Transform that denotes where the secondary grabbing object is grabbing the Interactable Object at. The GetSecondaryAttachPoint returns the Transform that determines where the secondary grabbing object is grabbing the Interactable Object at. ## Example `VRTK/Examples/005_Controller_BasicObjectGrabbing` uses the `VRTK_InteractTouch` and `VRTK_InteractGrab` scripts on the controllers to show how an interactable object can be grabbed and snapped to the controller and thrown around the game world. `VRTK/Examples/013_Controller_UsingAndGrabbingMultipleObjects` shows multiple objects that can be grabbed by holding the buttons or grabbed by toggling the button click and also has objects that can have their Using state toggled to show how multiple items can be turned on at the same time.