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

VRTK_BezierPointer

extends VRTK_WorldPointer

Overview

The Bezier Pointer emits a curved line (made out of game objects) from the end of the controller to a point on a ground surface (at any height). It is more useful than the Simple Laser Pointer for traversing objects of various heights as the end point can be curved on top of objects that are not visible to the user.

The laser beam is activated by default by pressing the Touchpad 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 Bezier Pointer script can be 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. It is also possible to attach the Bezier Pointer script to another object (like the [CameraRig]/Camera (head)) to enable other objects to project the beam. The controller parameter must be entered with the desired controller to toggle the beam if this is the case.

External Code Credit

  • The bezier curve generation code is in another script located at SteamVR_Unity_Toolkit/Scripts/Helper/CurveGenerator.cs and was heavily inspired by the tutorial and code from Catlike Coding.

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 obejct 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.
  • Pointer Length: The length of the projected forward pointer beam, this is basically the distance able to point from the controller potiion.
  • Pointer Density: The number of items to render in the beam bezier curve. A high number here will most likely have a negative impact of game performance due to large number of rendered objects.
  • Show Pointer Cursor: A cursor is displayed on the ground at the location the beam ends at, it is useful to see what height the beam end location is, however it can be turned off by toggling this.
  • Pointer Cursor Radius: The size of the ground pointer cursor. This number also affects the size of the objects in the bezier curve beam. The larger the raduis, the larger the objects will be.
  • Beam Curve Offset: The amount of height offset to apply to the projected beam to generate a smoother curve even when the beam is pointing straight.
  • Custom Pointer Tracer: A custom Game Object can be applied here to use instead of the default sphere for the beam tracer. The custom Game Object will match the rotation of the controller.
  • Custom Pointer Cursor: A custom Game Object can be applied here to use instead of the default flat cylinder for the pointer cursor.
  • Layers To Ignore: The layers to ignore when raycasting.
  • Valid Teleport Location Object: A custom Game Object can be applied here to appear only if the teleport is allowed (its material will not be changed ).
  • Rescale Pointer Tracer: Rescale each pointer tracer element according to the length of the Bezier curve.

Example

SteamVR_Unity_Toolkit/Examples/009_Controller_BezierPointer is used in conjunction with the Height Adjust Teleporter shows how it is possible to traverse different height objects using the curved pointer without needing to see the top of the object.

SteamVR_Unity_Toolkit/Examples/012_Controller_PointerWithAreaCollision shows how a Bezier Pointer with the Play Area Cursor and Collision Detection enabled can be used to traverse a game area but not allow teleporting into areas where the walls or other objects would fall into the play area space enabling the user to enter walls.

`SteamVR_Unity_Toolkit/Examples/036_Controller_CustomCompoundPointer' shows how to display an object (a teleport beam) only if the teleport location is valid, and can create an animated trail along the tracer curve.