RealDocs

ACharacter::BeginPlay

function Engine Since 4.0
#include "GameFramework/Character.h"
Access: public Specifiers: virtualoverride

Description

Called when the game starts or when the character is spawned into the world. Override to perform initialization that requires a fully constructed world and component tree.

Caveats & Gotchas

  • Always call Super::BeginPlay() — ACharacter's implementation initializes movement base state and other internal systems.
  • Components are guaranteed to be initialized by the time BeginPlay fires, but gameplay-relevant state (e.g. possessing controller) may not be set yet if the pawn is spawned before being possessed.

Signature

virtual void BeginPlay() override

Return Type

void

Example

Basic BeginPlay override C++
void AMyCharacter::BeginPlay()
{
    Super::BeginPlay();
    // Safe to access all components and the world here
    UE_LOG(LogTemp, Log, TEXT("Character spawned at %s"), *GetActorLocation().ToString());
}

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.