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::ChoosePlayerStartpicks a random freePlayerStartand ignores where anyone is.
- Worse,
AGameModeBase::ShouldSpawnAtStartSpotis true whenever the controller has aStartSpot, 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
- Respawns clear
StartSpot(ASLGameModeBase::RespawnAtNewStart), soFindPlayerStartasks
ChoosePlayerStart again each time.
- Free starts only. A start a pawn can't stand at is skipped, as the engine does. A "Play from Here" start
in PIE, or a level with every start blocked, falls back to the engine's pick.
- 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
- Scored (
SLSpawnSelection::Score), then picked at random among the best: every start within
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 **SystemLink | Spawning**. Every term is in points: |
|---|
| Setting | Default | Effect |
|---|---|---|
EnemyDistanceWeight / SafeEnemyDistance | 100 / 3000 cm | Points for distance from the nearest enemy, full at the safe distance |
EnemySightPenalty | 200 | Per enemy who can see the start; outweighs any distance on purpose |
NearbyTeammateBonus / TeammateRadius | 25 / 1500 cm | Per teammate nearby, so a team respawns together |
LastDeathPenalty / LastDeathRadius | 100 / 1000 cm | Come back somewhere other than where you died |
RecentSpawnPenalty / RecentSpawnSeconds | 150 / 3 s | Two players dying together don't share a start |
RepeatPenalty / RepeatMemorySeconds | 60 / 30 s | A used start loses points that fade to nothing over the memory, so the same few starts aren't reused |
OwnLastStartPenalty | 40 | A player doesn't come back where they last spawned |
PickTolerance | 25 | How 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.