VRTK_BasicTeleport
Overview
The basic teleporter updates the [CameraRig]
x/z position in the game world to the position of a World Pointer's tip location which is set via the WorldPointerDestinationSet
event. The y position is never altered so the basic teleporter cannot be used to move up and down game objects as it only allows for travel across a flat plane.
The Basic Teleport script is attached to the [CameraRig]
prefab.
Inspector Parameters
- Blink Transition Speed: The fade blink speed can be changed on the basic teleport script to provide a customised teleport experience. Setting the speed to 0 will mean no fade blink effect is present.
- Distance Blink Delay: A range between 0 and 32 that determines how long the blink transition will stay blacked out depending on the distance being teleported. A value of 0 will not delay the teleport blink effect over any distance, a value of 32 will delay the teleport blink fade in even when the distance teleported is very close to the original position. This can be used to simulate time taking longer to pass the further a user teleports. A value of 16 provides a decent basis to simulate this to the user.
- Headset Position Compensation: If this is checked then the teleported location will be the position of the headset within the play area. If it is unchecked then the teleported location will always be the centre of the play area even if the headset position is not in the centre of the play area.
- 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 teleporter that the destination is to be ignored so the user cannot teleport to that location. It also ensure the pointer colour is set to the miss colour.
- Target Tag Or Script List Policy: A specified VRTK_TagOrScriptPolicyList to use to determine whether destination targets will be acted upon by the Teleporter. If a list is provided then the 'Ignore Target With Tag Or Class' parameter will be ignored.
- Nav Mesh Limit Distance: The max distance the nav mesh edge can be from the teleport destination to be considered valid. If a value of
0
is given then the nav mesh restriction will be ignored.
Class Events
Teleporting
- Emitted when the teleport process has begun.Teleported
- Emitted when the teleport process has successfully completed.
Unity Events
Adding the VRTK_BasicTeleport_UnityEvents
component to VRTK_BasicTeleport
object allows access to UnityEvents
that will react identically to the Class Events.
OnTeleporting
- Emits the Teleporting class event.OnTeleported
- Emits the Teleported class event.
Event Payload
float distance
- The distance between the origin and the collided destination.Transform target
- The Transform of the collided destination object.Vector3 destinationPosition
- The world position of the destination marker.bool enableTeleport
- Whether the destination set event should trigger teleport.uint controllerIndex
- The optional index of the controller emitting the beam.
Class Methods
InitDestinationSetListener/2
public void InitDestinationSetListener(GameObject markerMaker, bool register)
- Parameters
GameObject markerMaker
- The game object that is used to generate destination marker events, such as a controller.bool register
- Determines whether to register or unregister the listeners.- Returns
- none
The InitDestinationSetListener method is used to register the teleport script to listen to events from the given game object that is used to generate destination markers. Any destination set event emitted by a registered game object will initiate the teleport to the given destination location.
ToggleTeleportEnabled/1
public void ToggleTeleportEnabled(bool state)
- Parameters
bool state
- Toggles whether the teleporter is enabled or disabled.- Returns
- none
The ToggleTeleportEnabled method is used to determine whether the teleporter will initiate a teleport on a destination set event, if the state is true then the teleporter will work as normal, if the state is false then the teleporter will not be operational.
Example
VRTK/Examples/004_CameraRig_BasicTeleport
uses the VRTK_SimplePointer
script on the Controllers to initiate a laser pointer by pressing the Touchpad
on the controller and when the laser pointer is deactivated (release the Touchpad
) then the user is teleported to the location of the laser pointer tip as this is where the pointer destination marker position is set to.
Updated less than a minute ago