VRTK_WorldPointer
extends VRTK_DestinationMarker
Overview
This abstract class provides any game pointer the ability to know 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
- 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. - 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 theWorldPointerDestinationSet
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.
- Target Tag Or Script List Policy: A specified VRTK_TagOrScriptPolicyList to use to determine whether the play area cursor collisions will be acted upon. If a list is provided then the 'Ignore Target With Tag Or Class' parameter will be ignored.
- Pointer Visibility: Determines when the pointer beam should be displayed.
- 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 Variables
public enum pointerVisibilityStates
- States of Pointer Visibility.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.
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.
Updated less than a minute ago