Skip to main content

Teleportation System

HeaderTeleportationSystem

The teleportation module enables users to move instantly within the environment using a raycast-driven pointer and a configurable arc. It works with Unity’s New Input System and the XR Interaction Toolkit to provide a smooth, VR-friendly teleport experience.


Overview

  • Draws an arc or straight ray from the controller to preview teleport destinations.
  • Supports selection and confirmation via configurable Input Actions.
  • Automatically disables the pointer visualization when the activation button is released.
  • Teleports the player’s transform to the detected ground point, applying a small offset along the surface normal to avoid clipping.

Requirements

  • Unity 2022.3 LTS or later
  • New Input System package enabled
  • XR Interaction Toolkit (for VR detection and controller tracking)
  • CharacterController or similar on the player’s body for collision handling (optional but recommended)

Setup

  1. Add the TeleporterController prefab component to your player rig:

TeleporterControllerPrefab

  • Assign the right-hand transform (rightHand).
  • Assign the player body transform (bodyTransform) that will teleport.
  • Provide materials for teleportable (lineTeleportableMat) and non-teleportable (lineNotTeleportableMat) surfaces.
  1. Configure the InputActionReferences:
    • teleportAction: button to activate the pointer (hold).
    • touchAction: (optional) for pointer feedback.
    • interactAction: button to confirm teleport destination.

TeleporterController

  1. Place the tag named Teleportable on the GameObjects that can be teleported.

TagTeleportable

  1. Set raycastLayers to include the valid teleport surface layers that the raycast will be able to hit.

RaycastLayers

  1. (Optional) Enable canRotate and adjust rotationSpeed to allow snap or smooth rotation while aiming.

Usage

  • Activate Pointer: Hold the teleportAction to show the pointer or arc.
  • Correct Aim: Point at a valid surface; the material and marker update to indicate validity.

CorrectTeleport

  • Wrong Aim: Aim at an invalid surface; the beam material will appear red and there will be no marker.

FailedTeleport

  • Confirm: Press the interactAction to teleport.
  • Automatic Cleanup: The pointer and marker hide automatically after teleporting.

Known Limitations

  • No built-in fade or blink transition; consider adding a screen fade for comfort.
  • Arc updates are frame-rate dependent; smoothing may be needed for consistent feedback.
  • Ground detection uses Unity physics; ensure valid colliders on teleport surfaces.
  • Teleport ignores obstacles between the marker and player; verify that landing areas are safe.