Guides
Guides

VRTK_HeadsetControllerAware

Overview

Determines whether the HMD is in line of sight to the controllers or if the headset is directly looking at one of the controllers.

Script Usage:

  • Place the VRTK_HeadsetControllerAware script on any active scene GameObject.

Inspector Parameters

  • Track Left Controller: If this is checked then the left controller will be checked if items obscure it's path from the headset.
  • Track Right Controller: If this is checked then the right controller will be checked if items obscure it's path from the headset.
  • Controller Glance Radius: The radius of the accepted distance from the controller origin point to determine if the controller is being looked at.
  • Custom Right Controller Origin: A custom transform to provide the world space position of the right controller.
  • Custom Left Controller Origin: A custom transform to provide the world space position of the left controller.
  • Custom Raycast: A custom raycaster to use when raycasting to find controllers.

Class Events

  • ControllerObscured - Emitted when the controller is obscured by another object.
  • ControllerUnobscured - Emitted when the controller is no longer obscured by an object.
  • ControllerGlanceEnter - Emitted when the controller is seen by the headset view.
  • ControllerGlanceExit - Emitted when the controller is no longer seen by the headset view.

Unity Events

Adding the VRTK_HeadsetControllerAware_UnityEvents component to VRTK_HeadsetControllerAware 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

  • RaycastHit raycastHit - The Raycast Hit struct of item that is obscuring the path to the controller.
  • VRTK_ControllerReference controllerReference - The reference to the controller that is being or has been obscured or being or has been glanced.

Class Methods

LeftControllerObscured/0

public virtual bool LeftControllerObscured()

  • Parameters
    • none
  • Returns
    • bool - Returns true if the path between the headset and the controller is obscured.

The LeftControllerObscured method returns the state of if the left controller is being obscured from the path of the headset.

RightControllerObscured/0

public virtual bool RightControllerObscured()

  • Parameters
    • none
  • Returns
    • bool - Returns true if the path between the headset and the controller is obscured.

The RightControllerObscured method returns the state of if the right controller is being obscured from the path of the headset.

LeftControllerGlanced/0

public virtual bool LeftControllerGlanced()

  • Parameters
    • none
  • Returns
    • bool - Returns true if the headset can currently see the controller within the given radius threshold.

the LeftControllerGlanced method returns the state of if the headset is currently looking at the left controller or not.

RightControllerGlanced/0

public virtual bool RightControllerGlanced()

  • Parameters
    • none
  • Returns
    • bool - Returns true if the headset can currently see the controller within the given radius threshold.

the RightControllerGlanced method returns the state of if the headset is currently looking at the right controller or not.

Example

VRTK/Examples/029_Controller_Tooltips displays tooltips that have been added to the controllers and are only visible when the controller is being looked at.