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
);
}
}
Unity Setup
- Create an empty object named
TeleportPad. - Add a collider (enable Is Trigger only if your interaction setup requires it).
- Add
VRC_Interactablecomponent. - Add
UdonBehaviourwith this compiled UdonSharp program. - Create another object named
TeleportTargetand position it where players should arrive. - Assign
TeleportTargettoteleportTarget.
Notes
- Teleport runs for the local player who pressed interact.
- For trigger-based teleport, use
OnPlayerTriggerEnterinstead ofInteract.
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
teleportTargetis assigned and script compiled without errors.
