Guides
These docs are for v2.1.0. Click to read the latest docs for v3.3.0.

VRTK_WorldPointer

Overview

This abstract class provides any game pointer the ability to know the the state of the implemented pointer. It extends the VRTK_DestinationMarker to allow for destination events to be emitted when the pointer cursor collides with objects.

The World Pointer also provides a play area cursor to be displayed for all cursors that utilise this class. The play area cursor is a representation of the current calibrated play area space and is useful for visualising the potential new play area space in the game world prior to teleporting. It can also handle collisions with objects on the new play area space and prevent teleporting if there are any collisions with objects at the potential new destination.

The play area collider does not work well with terrains as they are uneven and cause collisions regularly so it is recommended that handling play area collisions is not enabled when using terrains.

Inspector Parameters

  • Enable Teleport: If this is checked then the teleport flag is set to true in the Destination Set event so teleport scripts will know whether to action the new destination. This allows controller beams to be enabled on a controller but never trigger a teleport (if this option is unchecked).
  • Controller: The controller that will be used to toggle the pointer. 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.
  • Pointer Material: The material to use on the rendered version of the pointer. If no material is selected then the default WorldPointer material will be used.
  • Pointer Hit Color: The colour of the beam when it is colliding with a valid target. It can be set to a different colour for each controller.
  • Pointer Miss Color: The colour of the beam when it is not hitting a valid target. It can be set to a different colour for each controller.
  • Show Play Area Cursor: If this is enabled then the play area boundaries are displayed at the tip of the pointer beam in the current pointer colour.
  • Play Area Cursor Dimensions: Determines the size of the play area cursor and collider. If the values are left as zero then the Play Area Cursor will be sized to the calibrated Play Area space.
  • Handle Play Area Cursor Collisions: If this is ticked then if the play area cursor is colliding with any other object then the pointer colour will change to the Pointer Miss Color and the WorldPointerDestinationSet event will not be triggered, which will prevent teleporting into areas where the play area will collide.
  • Ignore Target With Tag Or Class: A string that specifies an object Tag or the name of a Script attached to an object and notifies the play area cursor to ignore collisions with the object.
  • Pointer Visibility: Determines when the pointer beam should be displayed:
  • On_When_Active only shows the pointer beam when the Pointer button on the controller is pressed.
  • Always On ensures the pointer beam is always visible but pressing the Pointer button on the controller initiates the destination set event.
  • Always Off ensures the pointer beam is never visible but the destination point is still set and pressing the Pointer button on the controller still initiates the destination set event.
  • Hold Button To Activate: If this is checked then the pointer beam will be activated on first press of the pointer alias button and will stay active until the pointer alias button is pressed again. The destination set event is emitted when the beam is deactivated on the second button press.
  • Activate Delay: The time in seconds to delay the pointer beam being able to be active again. Useful for preventing constant teleportation.

Class Methods

setPlayAreaCursorCollision/1

public virtual void setPlayAreaCursorCollision(bool state)

  • Parameters
  • bool state - The state of whether to check for play area collisions.
  • Returns
  • none

The setPlayAreaCursorCollision method determines whether play area collisions should be taken into consideration with the play area cursor.

IsActive/0

public virtual bool IsActive()

  • Parameters
  • none
  • Returns
  • bool - Is true if the pointer is currently active.

The IsActive method is used to determine if the pointer currently active.

CanActivate/0

public virtual bool CanActivate()

  • Parameters
  • none
  • Returns
  • bool - Is true if the pointer is able to be activated due to the activation delay timer being zero.

The CanActivate method checks to see if the pointer can be activated as long as the activation delay timer is zero.

ToggleBeam/1

public virtual void ToggleBeam(bool state)

  • Parameters
  • bool state - The state of whether to enable or disable the beam.
  • Returns
  • none

The ToggleBeam method allows the pointer beam to be toggled on or off via code at runtime. If true is passed as the state then the beam is activated, if false then the beam is deactivated.