Teleportation is a type of locomotion that allows the player to move around a VR environment with minimal discomfort. With teleportation, the player points the controller at a location they'd like to move to, then initiates the teleportation action, they are transitioned to that location via a rapid animation tuned to maintain player comfort.
Inside Elements we provide a high performance teleportation implementation that can customized as desired.
Getting started
You can add Teleportation to an existing scene as follows:
- Inside Elements drag DaydreamElements/Elements/Teleport/Prefabs/TeleportController.prefab
into your scene as a child of the Player object.
The
TeleportController
prefab must be pointing in the same direction as the player character for teleporting to function. - Drag your
Player
game object into the Player Transform slot. This transform will be used to move your player around the scene while teleporting. - Drag your "Controller" game object into the "Controller Transform" slot. This transform should be the Daydream controller, and its angle and position are used for calculating the arc position.
Customization
The core of the Teleportation implementation is the Visualizer, Detector, and Transition scripts. Each is independent and can be customized to fit your app's needs.
The Visualizer
script handles the visualization associated
with the teleportation. In the default app this consists of a disk showing
the target location and a drawn arc from the player to the location.
You can adjust this visualization by creating your own prefabs
and assigning them to the Target Prefab property on the TeleportController
object.
The Detector
script handles raycasting that determines
a valid teleportation location. By default this is arc-raycasting, but
it can be customized to line or any other kind of raycasting by subclassing
BaseTeleportDetector
and implementing your own raycasting.
The Transition
script handles the visual transition that occurs when a player
initiates a teleportation ction. By default we provide LinearTeleportTransition
which is a rapid movement animation from the
current location to the target location. You can create custom animations
by subclassing BaseTeleportTransition
and setting your custom transition
to the Transition property on the Teleport Controller
object.
Customizing Controller Buttons
You can customize which controller buttons trigger
teleporting by changing the Teleport Trigger property on TeleportController
.
Triggers are used as a way to decouple the teleport code from the controller (or
logic) that makes it operate. If you'd like to change the button that triggers
teleproting you can find more tiggers inside Common/Scripts/Utility/Triggers. We
provide triggers for a few common configurations such as using the trackpad
click, app button click, and trackpad edge contact.
You can easily build your own triggers by subclassing BaseActionTrigger
and
overriding TriggerActive()
.