Spawn points
Updated
A Spawn Point marks where the player enters a scene. When a scene loads in play, one spawn point is chosen and the player is placed on it, facing its direction. With several players in a room, a spawn point can spread them over nearby slots so nobody lands inside anyone else. Spawn points only place the player on arrival; to move the player during play, use a Teleport or spot and travel points.
Before you start
Section titled “Before you start”- Spawn points move the main camera, or the character its controller follows. Read Cameras and Camera director for the
Camera::relocaterule. - Their event reaches scripts through a Signal Emitter on the spawn point. See Events and signals.
The Spawn Point entity
Section titled “The Spawn Point entity”A Spawn Point is an entity (ent-spawn-point) with a comp-spawn-point. It faces where its transform points: its forward (-Z), flattened onto the ground. Rotate it to set the facing; the editor marker’s arrow shows it.
| Prop | Type | Default | Description |
|---|---|---|---|
priority |
number | 1 |
Selection weight when there are several spawn points, from 0.1 to 1. Higher is more likely. |
radius |
number | 0.6 |
The area, in metres, over which players are spread around the point. Scales with the entity. |
slots |
integer | 1 |
How many places players start on: the point itself and the rest around it. 1 puts everyone on the point. |
How a player is placed
Section titled “How a player is placed”- Which spawn point. Each scene load in play picks one active spawn point in a weighted draw by
priority. A spawn point enabled later joins the pool for the next draw; it moves no one by itself. - Which slot. A joining player takes the slot numbered by how many other players are already in the room, so each newcomer takes the next one; after the last slot, numbering starts again. Offline, it is slot 0, the point itself. The other slots stand on rings around the point, out to
radius, all facing the spawn direction. Keep the area flat and clear. - What moves. The spawn point moves the main camera, even while a script has cut to another camera. Without one, it moves the active camera. By the
Camera::relocaterule, if the camera follows a character, the character lands on the point; otherwise the camera stands there at eye height. A Character Controller, a NavMesh Agent or a rigid body is placed through its own API, so it does not snap back. - In XR. It moves the XR rig, or the body of the Character Controller carrying it. Entering an XR session draws a spawn point again. The placement becomes the rig’s home, which the XR Origin recenters to; see XR.
Spawn placement acts only in play. The editor never moves the authoring scene.
With a Signal Emitter on the spawn point’s entity:
| Event | Constant | Data | When |
|---|---|---|---|
Spawn |
Event |
{ position, rotation |
It placed the player. position is where it put the view; rotationY is the yaw at which a camera looking down -Z faces the spawn direction. |
Examples
Section titled “Examples”1. Welcome the player where they arrive
Section titled “1. Welcome the player where they arrive”#pragma lifecycle(startup)
function startup() { on('spawn', (event) => { if (event.eventType !== EventType.SpawnPoint.Place) return; const point = findEntity(event.entityId); log(`Spawned at ${point ? point.name : 'a spawn point'}`, event.data.position); emit('hud/toast', { text: `Welcome to ${point ? point.name : 'the world'}` }); });}A spawn point places the main camera when play starts; its Signal Emitter sends SpawnPoint::place and a script logs where the player arrived.
Read the arrival in the script log. Drag to look around, scroll to zoom.
All spawn points share the same signal, so one listener hears whichever was chosen. event.entityId identifies it, and the script shows its name in a toast. Name spawn points after their area (“North Gate”, “Harbour”) and this becomes a free location message.
Snippets
Section titled “Snippets”1. Prefer a spawn point after a checkpoint
Section titled “1. Prefer a spawn point after a checkpoint”#pragma lifecycle(startup)
function startup() { // Each checkpoint is a trigger named 'Checkpoint N' with a Signal Emitter 'checkpoint', // next to a Spawn Point named 'Checkpoint N Spawn'. on('checkpoint', (event) => { if (event.eventType !== EventType.PhysicsCollider.IntersectionEnter) return; const checkpoint = findEntity(event.entityId); const point = checkpoint && findEntity(`${checkpoint.name} Spawn`); if (!point) return; // Make this checkpoint's spawn the likeliest one for the next load. point.getComponent(SpawnPointComponent).setProps({ priority: 1 }); log('Checkpoint reached:', checkpoint.name); });}When the player walks into a checkpoint trigger, the script finds the spawn point named after it and raises its priority to the maximum. Give every other spawn point a low priority such as 0.1, and reloading the scene after a defeat very likely puts the player back at the last checkpoint. For a guaranteed respawn without reloading, use the Character Controller’s teleport instead.
2. Line players up for a group photo
Section titled “2. Line players up for a group photo”#pragma lifecycle(startup)
function startup() { const stage = findEntity('Stage Spawn').getComponent(SpawnPointComponent); // Spread up to 8 players over a 3 m circle on the stage. stage.setProps({ slots: 8, radius: 3 });}With slots: 8, the first player stands on the point and the next seven on rings around it, out to three metres, all facing the stage direction. Each joining player takes the next slot.
Common mistakes
Section titled “Common mistakes”- Expecting a spawn point to move players during play. Spawning happens on scene load. Enabling a spawn point later only affects the next draw. Use a teleport or a spot point to move players now.
- Players spawn facing the wrong way. The facing is the entity’s
-Z. Rotate the spawn point entity itself. - Slots on uneven ground. Slots move players only in X and Z. Keep the area flat and clear.
- Several spawn points but always the same one. Check
priority: a point with1is ten times more likely than one with0.1. - No event received.
SpawnPoint::placeneeds a Signal Emitter with a signal on the spawn point entity itself.