Basic Teleport Pad (UdonSharp)

This script teleports a player to a target transform when they interact with the object.

Category: Interaction Systems

Use Case

  • Portal pad
  • Spawn relocation point
  • Elevator destination shortcut

UdonSharp Script

using UdonSharp;
using UnityEngine;
using VRC.SDKBase;
using VRC.Udon;

public class BasicTeleportPad : UdonSharpBehaviour
{
    [Header("Where the player will be moved to")]
    public Transform teleportTarget;

    public override void Interact()
    {
        VRCPlayerApi localPlayer = Networking.LocalPlayer;
        if (localPlayer == null || teleportTarget == null)
        {
            return;
        }

        localPlayer.TeleportTo(
            teleportTarget.position,
            teleportTarget.rotation,
            VRC_SceneDescriptor.SpawnOrientation.AlignPlayerWithSpawnPoint,
            true
        );
    }
}

License:

Unity Setup

  1. Create an empty object named TeleportPad.
  2. Add a collider (enable Is Trigger only if your interaction setup requires it).
  3. Add VRC_Interactable component.
  4. Add UdonBehaviour with this compiled UdonSharp program.
  5. Create another object named TeleportTarget and position it where players should arrive.
  6. Assign TeleportTarget to teleportTarget.

Notes

  • Teleport runs for the local player who pressed interact.
  • For trigger-based teleport, use OnPlayerTriggerEnter instead of Interact.

Extra Tips and Troubleshooting

Context

Teleport scripts are core utility interactions and should prioritize reliability and clear destinations.

Tips and Tricks

  • Add clear signage where teleports lead.
  • Keep destination colliders clean to avoid spawn clipping.

Troubleshooting

  • If teleport fails, verify teleportTarget is assigned and script compiled without errors.

Related Content

Official References