PlayerSpawner¶
Class ยท server and client scripts
PlayerSpawner controls how the server spawns and respawns characters for connected players. Access it through World.PlayerSpawner.
Example
CharacterPrefab¶
CharacterPrefab is the prefab name used when spawning a player's character.
Default "Character"
RespawnDelay¶
RespawnDelay is the delay in seconds after a character dies before PlayerSpawner spawns a replacement while AutoSpawn is true.
Default 5
AutoSpawn¶
AutoSpawn spawns a character when a player joins and respawns one after RespawnDelay seconds when the current character dies. Set it to false to call Spawn from scripts instead.
Default true
Spawn¶
Spawn creates a new character for player, replaces any existing character bound to that player, and returns the spawned character entity.
| Parameter | Type | Description |
|---|---|---|
self |
PlayerSpawner |
World.PlayerSpawner. |
player |
Entity |
Player entity to spawn a character for. |
options |
PlayerSpawnOptions? |
Optional PlayerSpawnOptions choosing a spawn anchor entity (At) or prefab override (Prefab). |
Returns The newly spawned character entity.