Guides
Guides

VRTK_InteractNearTouch

Overview

Determines if a GameObject can initiate a near touch with an Interactable Object.

Required Components:

  • VRTK_InteractTouch - The touch component to determine the actual interacting GameObject that will deal with the near touch interaction. This must be applied on the same GameObject as this script if one is not provided via the Interact Touch parameter.

Script Usage:

  • Place the VRTK_InteractNearTouch script on either:
    • The Interact Touch GameObject.
    • Any other scene GameObject and provide a valid VRTK_InteractTouch component to the Interact Touch parameter of this script.

Inspector Parameters

  • Collider Radius: The radius of the auto generated collider if a Custom Collider Container is not supplied.
  • Custom Collider Container: An optional GameObject that contains the compound colliders to represent the near touching object. If this is empty then the collider will be auto generated at runtime.
  • Interact Touch: The Interact Touch script to associate the near touches with. 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

  • ControllerNearTouchInteractableObject - Emitted when a valid object is near touched.
  • ControllerNearUntouchInteractableObject - Emitted when a valid object is no longer being near touched.

Unity Events

Adding the VRTK_InteractNearTouch_UnityEvents component to VRTK_InteractNearTouch 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

GetNearTouchedObjects/0

public virtual List<GameObject> GetNearTouchedObjects()

  • Parameters
    • none
  • Returns
    • List<GameObject> - A list of GameObjects that are being near touched.

The GetNearTouchedObjects method returns all of the GameObjects that are currently being near touched.

ForceNearTouch/1

public virtual void ForceNearTouch(GameObject obj)

  • Parameters
    • GameObject obj - The GameObject to attempt to force near touch.
  • Returns
    • none

The ForceNearTouch method will attempt to force the controller to near touch the given GameObject.

ForceStopNearTouching/1

public virtual void ForceStopNearTouching(GameObject obj = null)

  • Parameters
    • GameObject obj - An optional GameObject to only include in the force stop. If this is null then all near touched GameObjects will be force stopped.
  • Returns
    • none

The ForceStopNearTouching method will stop the Interact Touch GameObject from near touching an Interactable Object even if the Interact Touch GameObject is physically touching the Interactable Object still.

GetNearTouchedObjects/0

public virtual List<GameObject> GetNearTouchedObjects()

  • Parameters
    • none
  • Returns
    • List<GameObject> - A list of GameObjects that are being near touched.

The GetNearTouchedObjects method returns all of the GameObjects that are currently being near touched.