RealDocs

APawn::DispatchRestart

function Engine Since 4.0
#include "GameFramework/Pawn.h"
Access: public

Description

Wrapper that calls Restart() and, when appropriate, PawnClientRestart(). The GameMode calls this after possession to ensure both server-side and client-side restart paths run correctly.

Caveats & Gotchas

  • This is the preferred entry point for triggering a pawn restart; calling Restart() or PawnClientRestart() directly bypasses the flag logic that decides which restart path is appropriate.
  • bCallClientRestart should only be true for locally owned player pawns. Passing true for an AI pawn or a remote player pawn results in redundant or incorrect client-side setup.
  • In networked games, DispatchRestart is called on the server; the client gets PawnClientRestart through the PlayerController's ClientRestart RPC, not through a direct call from this function.

Signature

void DispatchRestart(bool bCallClientRestart)

Parameters

Name Type Description Default
bCallClientRestart bool If true and this is a locally owned player pawn, PawnClientRestart() is called in addition to Restart().

Return Type

void

Example

Trigger a manual pawn restart from a custom GameMode C++
void AMyGameMode::RespawnPlayer(AController* Controller)
{
	APawn* NewPawn = SpawnDefaultPawnFor(Controller, ChoosePlayerStart(Controller));
	if (NewPawn)
	{
		Controller->Possess(NewPawn);
		bool bIsLocal = NewPawn->IsLocallyControlled();
		NewPawn->DispatchRestart(bIsLocal);
	}
}

Version History

Introduced in: 4.0

Version Status Notes
5.6 stable

Feedback

Was this helpful?

Suggest an edit

Select a field above to begin editing.