Teleport Via Code
Often during an experience you will need to reposition the user's avatar. This can be done using the SDK's Locomotion feature. It will even allow you to specify an alternative mode to what you have set in your Locomotion Settings.
Teleport
Often with teleporting, you will want to change the position without affecting the current rotation. This can be done in the following ways:
Simple, Position Only
using ImmerseSDK.Interaction.Locomotion;
// Teleport to 0,0,0
Teleport.TeleportTo(Vector3.zero);
Complex, Override Default Values
using ImmerseSDK.Interaction.Locomotion;
var position = new Vector3(1, 0, 0); // Target position
var forceTeleport = false; // Don't teleport if disabled with Teleport.AllowTeleporting
var delay = 0f; // Teleport immediately
Teleport.TeleportTo(position, LocomotionSettings.TeleportOption.Instant, forceTeleport, delay);
Teleport and Rotate
Other times you will need to set the rotation of the avatar while teleporting. This can be done by passing in a rotation value.
Simple, Position & Rotation Only
using ImmerseSDK.Interaction.Locomotion;
// Teleport to 0,0,0 rotated by 90 degrees
Teleport.TeleportTo(Vector3.zero, Quaternion.Euler(0, 90, 0);
Complex, Override Default Values
using ImmerseSDK.Interaction.Locomotion;
var position = new Vector3(1, 0, 0); // Target position
var rotation = Quaternion.identity; // Reset rotation to 0,0,0
var forceTeleport = true; // Teleport even if disabled with Teleport.AllowTeleporting
var delay = 1f; // Teleport after 1 second
Teleport.TeleportTo(position, rotation, LocomotionSettings.TeleportOption.Instant, forceTeleport, delay);
Updated almost 2 years ago