AGameModeBase::PostLogin
#include "GameFramework/GameModeBase.h"
Access: public
Specifiers: virtual
Description
Called after a player has successfully logged in. This is the first place it is safe to call replicated functions on the new PlayerController.
Caveats & Gotchas
- • Do not call `RestartPlayer` or spawn pawns from here directly if you also override `HandleStartingNewPlayer` — `PostLogin` calls `HandleStartingNewPlayer` at the end, which will spawn the pawn. Double-calling will result in two pawns.
- • The `FGameModeEvents::GameModePostLoginEvent` global delegate is broadcast here. Skipping `Super::PostLogin` will prevent plugins (including Online Subsystem integrations) from receiving the login notification.
- • Replication is established by the time `PostLogin` runs, but the client has not yet received the full initial bunch. Do not rely on client-side state being fully populated.
Signature
virtual void PostLogin(APlayerController* NewPlayer) Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| NewPlayer | APlayerController* | The player controller that has just successfully logged in. | — |
Return Type
void Example
Grant starting items on login C++
void AMyGameMode::PostLogin(APlayerController* NewPlayer)
{
Super::PostLogin(NewPlayer); // spawns the pawn via HandleStartingNewPlayer
// Pawn is now spawned; grant starting items
if (AMyCharacter* Char = Cast<AMyCharacter>(NewPlayer->GetPawn()))
{
Char->GrantStartingLoadout();
}
} See Also
Version History
Introduced in: 4.14
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?