Skip to content
StoneFox edited this page Jun 8, 2016 · 2 revisions

[VRTK_SimplePointer]

The Simple Pointer emits a coloured beam from the end of the controller to simulate a laser beam. It can be useful for pointing to objects within a scene and it can also determine the object it is pointing at and the distance the object is from the controller the beam is being emitted from.

The laser beam is activated by default by pressing the Grip on the controller. The event it is listening for is the AliasPointer events so the pointer toggle button can be set by changing the Pointer Toggle button on the VRTK_ControllerEvents script parameters.

The Simple Pointer script is attached to a Controller object within the [CameraRig] prefab and the Controller object also requires the VRTK_ControllerEvents script to be attached as it uses this for listening to the controller button events for enabling and disabling the beam.

The following script parameters are available:

  • 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).
  • 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.
  • Beam Always On: If this is checked the the pointer beam is always visible but the Destination Set event is still only emitted when the assigned button is pressed.
  • Activate Delay: The time in seconds to delay the pointer beam being able to be active again. Useful for preventing constant teleportation.
  • Pointer Thickness: The thickness and length of the beam can also be set on the script as well as the ability to toggle the sphere beam tip that is displayed at the end of the beam (to represent a cursor).
  • Pointer Length: The distance the beam will project before stopping.
  • Show Pointer Tip: Toggle whether the cursor is shown on the end of the pointer beam.

The Simple Pointer object extends the VRTK_WorldPointer abstract class and therefore emits the same events and payload.

An example of the VRTK_SimplePointer script can be viewed in the scene SteamVR_Unity_Toolkit/Examples/003_Controller_SimplePointer and code examples of how the events are utilised and listened to can be viewed in the script SteamVR_Unity_Toolkit/Examples/Resources/Scripts/VRTK_ControllerPointerEvents_ListenerExample.cs

Clone this wiki locally