Return to Spawn Button

This script teleports the local player back to a designated spawn point when they interact with a button.

Category: Interaction Systems

UdonSharp Script

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

public class ReturnToSpawnButton : UdonSharpBehaviour
{
    public Transform spawnTarget;

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

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

License:

Unity Setup

  1. Create a button object with collider.
  2. Add VRC_Interactable.
  3. Add this UdonSharp program.
  4. Create/choose SpawnTarget transform.
  5. Assign spawnTarget in the inspector.

Useful Variations

  • One button per zone to return players to lobby
  • Separate spawn targets for floor sections
  • Pair with UI label: "Return to Hub"

Extra Tips and Troubleshooting

Tips and Tricks

  • Place return buttons in dead-end or high confusion zones.
  • Use consistent naming and iconography for hub return controls.

Troubleshooting

  • If rotation is wrong, adjust spawnTarget orientation transform.

Related Content

Prefab Setup Notes

Import the prefab or script into a throwaway test scene before adding it to a live world. Confirm inspector references, ownership behavior, sync, triggers, UI hooks, and audio or object links before moving it into the production scene.

Testing Checklist

  • Test once as a local player and again with a second client or late joiner if the behavior can affect more than one player.
  • Confirm ownership, sync, trigger zones, UI references, and audio or object references are assigned intentionally.
  • Check desktop and VR interaction distance so players can actually use the feature in context.
  • Keep a backup of the scene before changing prefabs, UdonBehaviours, or serialized references.

Related Pages

Official References