Death and respawn
Modules PulseRespawn (depends on PulseCombat, PulseInventory and PulseAbility) and PulseRespawnUI (the death screen, depends on PulseHUD). When a player’s pawn dies, the player waits a few seconds, sees the death screen, picks a respawn point (or lets a rule pick one) and comes back. What the player carried falls into a death bag that only the player and its team can empty.
Overview
| Type | What it is |
|---|---|
UPulseRespawnComponent | On the player controller: follows the life state of the pawn’s combat component, the waiting time, the choice of the point (server request), the death bag |
APulseRespawnPointActor | Pulse Respawn Point: a place in the level, with a team and tags |
APulseDeathBag | The bag a dead player leaves: an inventory, its owner as player id, a lifetime |
UPulseRespawnSubsystem | The respawn points of the world, on every machine |
FPulseRespawnRule | How a point is picked when the player does not choose: Nearest, Random, Last Used (instanced structs) |
UPulseDeathScreenWidget | Pulse Death Screen: “You died”, the countdown and one button per point |
UPulseRespawnSettings | Project Settings > Pulse > Core > Respawn |
UPulseRespawnUISettings | Project Settings > Pulse > Core > Respawn UI |
Setup
- The pawn needs a Pulse combat component (
UPulseCombatComponent): its life state tells the respawn component when the player dies. Pawns without one call Handle Player Died on the respawn component themselves. - Turn on the automatic Respawn Component in Project Settings > Pulse > Core > Respawn (or with the setup step “Respawn” in the Pulse window). It goes on every player controller.
- Place Pulse Respawn Point actors. Without points the player comes back at a player start of the game mode (Use Player Start Fallback).
- For the death screen the Pulse HUD has to be on (
bEnableHUD). The screen goes on the main HUD stack and shows the cursor through the Pulse player input manager.
The flow
The state of a player is one struct, FPulseRespawnState (phase, the stamps on the Pulse game clock, the death place, the last point, the number of deaths). It changes only through pure functions in Pulse::Respawn (PulseRespawnTypes.h), which the specs test without a world:
| Function | What it does |
|---|---|
MakeDead | Dead, the stamps of the delays (game clock), the death place, one more death; a dead state stays as it is |
CheckChoice | Whether a respawn request is allowed: dead, the delay passed, the point exists, is usable by the team and selectable |
ChoosePoint | The point a rule picks among the points of the player’s team |
MakeRespawned | Alive, stamps cleared, the point as last point |
FilterByTeam | The points a team can use (enabled, no team or the same team) |
CanAccessBag | Whether a player may empty a death bag |
- Death (server): the combat component reports the death, the respawn component sets the state with
MakeDeadand drops the death bag. The state replicates to the owning client (push model, owner only). - Waiting: the death screen counts down on the game clock (
Respawn Delay, 5 s). With Auto Respawn the player comes back by itself afterAuto Respawn Delay, at the point of the rule. - Choice: a button on the death screen calls
RequestRespawn(PointId). A client sends a server RPC with a request id of the Pulse request subsystem; the server checks it withCheckChoiceand answers with anFPulseResult. A refusal shows its reason on the screen (and is broadcast onPulse.Message.Request.Failed). The button Respawn lets the rule pick. - Respawn (server): in mode Revive the pawn is moved to the point and revived (
UPulseCombatComponent::Revivewith Respawn Health); in mode Restart the old pawn is destroyed and the game mode spawns a new one there (RestartPlayerAtTransform). The state becomes Alive,Pulse.Message.Respawn.Respawnedis broadcast.
A pawn revived by something else (a cheat, a teammate) ends the waiting where it stands.
Respawn points
A Pulse Respawn Point holds one FPulseRespawnPoint:
| Field | What it is |
|---|---|
| Point Id | Stable id; empty uses the actor name (the server writes it into the replicated point). Give saved points an id of their own. |
| Display Name | Name on the death screen |
| Team | Team that may use it (Pulse.Team.*); empty for every player |
| Tags | What kind of point it is (Pulse.Respawn.Point.* or tags of the game); rules can ask for them |
| Enabled | Off: nobody uses it |
| Selectable | Off: only the rule picks it, the death screen does not show it |
SetPointEnabled and SetPointTeam change a point while playing (server). Games with points of their own (beds, camps) add them with UPulseRespawnSubsystem::SetPoint on every machine.
Rules
The rule of the settings (or of a respawn component) picks the point when the player does not choose one. Every rule only sees the points of the player’s team; Required Tags narrows them further (all points when none has the tags).
| Rule | Picks |
|---|---|
| Nearest (default) | The point nearest to the death place; Min Distance skips points too close to it while farther ones exist |
| Random | A random point, the same for the same seed (the player id and the number of deaths) |
| Last Used | The point of the last respawn while it is usable, else its Fallback rule (Nearest when empty) |
Your own rule: a USTRUCT derived from FPulseRespawnRule that overrides Choose. Rules keep no state; what they know about the player comes in FPulseRespawnContext.
Death bag
When a player dies, its inventory (UPulseInventoryComponent of the controller, pawn or player state) falls into an APulseDeathBag on the ground below the death place:
- All or nothing: the player’s contents become
FPulseInventorySaveDataand are imported into the bag (Pulse::Respawn::Bag::PlanDropIntoBag: layout, persisted traits, every stack with its traits and id); only when every stack imports, the player’s stacks are removed, both in oneApplyTogether. Otherwise the player keeps everything and the log says why. - Rights: the owner is a player id (
FPulseDeathBagState::OwnerPlayerId), not an actor, so it stays valid after a respawn. The owner and, with Team Can Access Bag, players of the owner’s team may empty it; others see “Not yours”. The bag’s inventory asksPulse::Respawn::CanAccessBaginCanRequesterModify, so single items move with the inventory requests too. - Taking: the interaction (“Take all”) moves everything that fits into the player’s inventory (
Pulse::Respawn::Bag::PlanTakeAll, stack by stack with the instance traits; a stack that fits in part moves that part). The bag needs a replicated interaction (UPulseRepInteractAbility). - Lifetime: the bag disappears after Death Bag Lifetime (game clock, 600 s; 0 keeps it) and, with Destroy Empty Bag, when it is empty.
Pulse.Message.Respawn.BagDroppedis broadcast when it is dropped.
The equipment stays with the player.
Messages
| Channel | Payload | Context |
|---|---|---|
Pulse.Message.Respawn.Respawned | FPulseRespawnedMessage (point id, place, chosen or by the rule) | player: the controller, target: the pawn, amount 1 |
Pulse.Message.Respawn.BagDropped | FPulseDeathBagMessage (bag, owner and rights, stacks) | player: the controller, target: the bag, amount: stacks |
Both come from the server.
Blueprint and C++
| Function | Where | What it does |
|---|---|---|
Find Respawn Component | any | The respawn component of a controller, pawn or player state |
Request Respawn | owning client or server | Asks for the respawn at a point (none: the rule) |
Try Respawn | server | Respawns now, returns the result |
Handle Player Died | server | Sets the player dead without a combat component |
Get State, Is Dead, Get Seconds Until Respawn, Get Selectable Points | owning client and server | For your own death screen |
On State Changed, On Respawned | events | Died or respawned; came back (server) |
Your own death screen: set Death Screen Class in the Respawn UI settings to any activatable widget, or derive from Pulse Death Screen and bind Backdrop, TitleText, CountdownText, MessageText, PointList and RespawnButton. The default screen makes its buttons from the Modal Action Button Class of the HUD settings.
Settings
| Setting | Default | Description |
|---|---|---|
Timing | 5 s, no automatic respawn (30 s) | Delays on the game clock |
Rule | Nearest | How a point is picked when the player does not choose |
bAllowChoice | true | Players choose a point on the death screen |
Mode | Revive | Revive the pawn, or Restart with a new pawn |
RespawnHealth | 1 | Health after the respawn |
bUsePlayerStartFallback | true | A player start when there is no point |
bDropDeathBag | true | The inventory falls into a death bag |
DeathBagClass | APulseDeathBag | The bag actor |
DeathBagLifetime | 600 | Game seconds until the bag disappears; 0 keeps it |
bTeamCanAccessBag | true | The owner’s team may empty the bag |
bDestroyEmptyBag | true | An empty bag goes away |
RespawnComponent | off | Automatic respawn component on every player controller |
bShowDeathScreen (Respawn UI) | true | The death screen on the Pulse HUD |
DeathScreenClass (Respawn UI) | UPulseDeathScreenWidget | The death screen |
DeathScreenStack (Respawn UI) | Pulse.HUD.Stack.Main | HUD stack of the screen |
DeathScreenInputContext, DeathScreenInputPriority (Respawn UI) | menu, 450 | Input while the screen is open |
Example
Play the PulseCore example map with a listen server and a client, then PulseCoreGrant (it calls PulseRespawnGrant: a respawn component and a point at the pawn when the level has none). PulseCombatKill kills the player: the death screen counts down, the point button and Respawn bring the player back. The bag lies where the player died; PulseRespawnTeam Enemy on the other player shows that it is “not yours”, PulseRespawnTakeBag empties it for the owner or a teammate.
Cheats
See Console.