Guides

VRTK_BezierPointerRenderer

extends VRTK_BasePointerRenderer

Overview

A visual pointer representation of a curved beam made from multiple objects with an optional cursor at the end.

The bezier curve generation code is in another script located at VRTK/Source/Scripts/Internal/VRTK_CurveGenerator.cs and was heavily inspired by the tutorial and code from Catlike Coding.

Optional Components:

  • VRTK_PlayAreaCursor - A Play Area Cursor that will track the position of the pointer cursor.
  • VRTK_PointerDirectionIndicator - A Pointer Direction Indicator that will track the position of the pointer cursor.

Script Usage:

  • Place the VRTK_BezierPointerRenderer script on the same GameObject as the Pointer script it is linked to.
  • Link this Pointer Renderer script to the Pointer Renderer parameter on the required Pointer script.

Script Dependencies:

  • A Pointer script to control the activation of this Pointer Renderer script.

Inspector Parameters

  • Maximum Length: The maximum length of the projected beam. The x value is the length of the forward beam, the y value is the length of the downward beam.
  • Tracer Density: The number of items to render in the bezier curve tracer beam. A high number here will most likely have a negative impact of game performance due to large number of rendered objects.
  • Cursor Radius: The size of the ground cursor. This number also affects the size of the objects in the bezier curve tracer beam. The larger the radius, the larger the objects will be.
  • Height Limit Angle: The maximum angle in degrees of the origin before the beam curve height is restricted. A lower angle setting will prevent the beam being projected high into the sky and curving back down.
  • 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.
  • Rescale Tracer: Rescale each tracer element according to the length of the Bezier curve.
  • Cursor Match Target Rotation: The cursor will be rotated to match the angle of the target surface if this is true, if it is false then the pointer cursor will always be horizontal.
  • Collision Check Frequency: The number of points along the bezier curve to check for an early beam collision. Useful if the bezier curve is appearing to clip through teleport locations. 0 won't make any checks and it will be capped at Pointer Density. The higher the number, the more CPU intensive the checks become.
  • Custom Tracer: A custom game object to use as the appearance for the pointer tracer. If this is empty then a collection of Sphere primitives will be created and used.
  • Custom Cursor: A custom game object to use as the appearance for the pointer cursor. If this is empty then a Cylinder primitive will be created and used.
  • Valid Location Object: A custom game object can be applied here to appear only if the location is valid.
  • Invalid Location Object: A custom game object can be applied here to appear only if the location is invalid.

Class Methods

UpdateRenderer/0

public override void UpdateRenderer()

  • Parameters
    • none
  • Returns
    • none

The UpdateRenderer method is used to run an Update routine on the pointer.

GetPointerObjects/0

public override GameObject[] GetPointerObjects()

  • Parameters
    • none
  • Returns
    • GameObject[] - An array of pointer auto generated GameObjects.

The GetPointerObjects returns an array of the auto generated GameObjects associated with the pointer.

Example

VRTK/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.

`VRTK/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.