Reference · Updated 2552.10.22.15.22

Spawning

Where a player appears when they join a match and every time they respawn. Server only; all of it lives in ASLGameModeBase and the world-free SLSpawnSelection.

Where a player appears when they join a match and every time they respawn. Server only; all of it lives in ASLGameModeBase and the world-free SLSpawnSelection.

#1. Why we don't use the engine's pick

  • AGameModeBase::ChoosePlayerStart picks a random free PlayerStart and ignores where anyone is.
  • Worse, AGameModeBase::ShouldSpawnAtStartSpot is true whenever the controller has a StartSpot, which it
  • always has after joining. So every respawn went back to the player's first start for the whole match, and an enemy soon learned to wait there.

#2. How a start is chosen

  1. Respawns clear StartSpot (ASLGameModeBase::RespawnAtNewStart), so FindPlayerStart asks
  2. ChoosePlayerStart again each time.

  1. Free starts only. A start a pawn can't stand at is skipped, as the engine does. A "Play from Here" start
  2. in PIE, or a level with every start blocked, falls back to the engine's pick.

  1. Each free start is described (DescribeStart) from the living pawns:
    • distance to the nearest enemy
    • how many enemies have a clear line from their eyes to the start's eyes or body (ECC_Visibility)
    • teammates within TeammateRadius
    • whether it is near where this player last died
    • how long since anyone spawned there
    • whether it is where this player spawned last time
  1. Scored (SLSpawnSelection::Score), then picked at random among the best: every start within
  2. PickTolerance points of the top score (SLSpawnSelection::GetBest). Random so nobody can learn where an enemy will appear.

An enemy is anyone not on the player's side (SLTeams::AreTeammates), so a free-for-all needs no special case. Dead pawns count as nobody.

#3. Tuning

FSLSpawnScoring on the game mode, under **SystemLinkSpawning**. Every term is in points:
SettingDefaultEffect
EnemyDistanceWeight / SafeEnemyDistance100 / 3000 cmPoints for distance from the nearest enemy, full at the safe distance
EnemySightPenalty200Per enemy who can see the start; outweighs any distance on purpose
NearbyTeammateBonus / TeammateRadius25 / 1500 cmPer teammate nearby, so a team respawns together
LastDeathPenalty / LastDeathRadius100 / 1000 cmCome back somewhere other than where you died
RecentSpawnPenalty / RecentSpawnSeconds150 / 3 sTwo players dying together don't share a start
RepeatPenalty / RepeatMemorySeconds60 / 30 sA used start loses points that fade to nothing over the memory, so the same few starts aren't reused
OwnLastStartPenalty40A player doesn't come back where they last spawned
PickTolerance25How close to the best a start must be to be picked

#4. Joining

A player's team is assigned before Super::InitNewPlayer, which picks their first start, so in a team game it can already favour teammates. At the start of a lobby match the countdown holds everyone still, so a first spawn in sight matters less than a respawn.

#5. Testing

  • SystemLink.SpawnSelection.* automation tests cover the scoring and the pick.
  • Sight lines and distances in a real level need a LAN or split-screen match: respawns should land at
  • different starts, and never in an enemy's view when a hidden start exists. A "Play from Here" start bypasses all of this.