Recipes
Spawn points checkpoints and respawn flow
Players need a place to start, checkpoints to save progress mid-level, and a way back after death or a fall. The player's start and respawn are NOT a script: a spawn location is a
SpawnPointComponent entity and the character policy spawns and respawns the body. Checkpoints and the death-return are the script pattern, authored as durable state plus a handler.engine v1.0.234since script-semantic-patch-ops.v1, action-catalog.v1.0.232, persistence.v1, prefabs.v1Copy for LLM
Use this for
placing where players start; save-point checkpoints; sending a dead or fallen player back to the last checkpoint; spawning entities from a prefab or template
Not for
matchmaking room placement (see multiplayer-replication-and-rooms); health and death rules (see combat-damage-and-respawn)
Pairs with: Combat damage health and respawn scripting, Saves persistence player progress and data stores, Physics colliders rigid bodies triggers and joints
The recipe
- Player spawns: place Spawn Point entities, the
spawn_pointpreset (aTransformComponentfor the location and facing plus aSpawnPointComponent). Set the component'steamKeyfor a per-team spawn and itspriorityand spreadradiusso simultaneous spawns do not overlap. The game's character policy spawns a body for every seat that joins, its spawn selector chooses among the eligible points, and its respawn rule brings an eliminated player back. You do not script the initial player spawn (see player-characters-and-spawns and teams-and-team-play). - Seed the checkpoint position as durable state:
writeTypedStateValue{ "storeKey":"progress", "recordKey":"player", "field":"checkpoint", "valueType":"vector3", "value": <start position> }. - Place checkpoint entities with a trigger
ColliderComponent(collision:"trigger"). On cross, react withaddTriggerHandler{ "handlerKey":"onCheckpoint" }and inside itwriteTypedStateValuethe newcheckpointposition (read the checkpoint entity's transform in a GessaScript body viactx.entity.readComponentif you need exact coordinates). - Return on death: from the death handler (see combat-damage-and-respawn),
readTypedStateValuethecheckpointinto a binding, then teleport the player from a GessaScript body withctx.world.teleportPlayer. To place a fresh non-player entity instead,spawnEntityFromTemplate{ "scope":{...}, "prefabKey": <prefab key>, "config": { ...inline overrides } }.
Pitfalls
- A player's spawn point is a
SpawnPointComponententity, not a tagged capsule you spawn from in a script; the character policy reads it. Keep the player spawn (component plus policy) and the checkpoint save (durable state plus a handler) as two separate concerns. spawnEntityFromTemplaterequires EITHERtemplateKeyORprefabKey, and itsconfigvalues must be validated inline literals, not arbitrary JSON.- Spawn and teleport ops carry
requiresAuthority; they run on the server authority, not the client. - Storing the checkpoint as
vector3state (not on a component) is what makes it survive death and reload; a position written only on the entity is lost when the entity despawns. ctx.world.teleportPlayeris gated byworlds.teleport_authority; use it for the player,spawnEntityFromTemplatefor fresh entities.
Verify
simulation_runto prove crossing a checkpoint updates the stored position and death returns the player there.project_get_graph_snapshotto confirm the Spawn Point entities and the checkpoint triggers exist.