AGameModeBase::Logout
#include "GameFramework/GameModeBase.h"
Access: public
Specifiers: virtual
Description
Called when a controller with a `PlayerState` leaves the game or is destroyed. Use this to clean up per-player data and broadcast departure events.
Caveats & Gotchas
- • This is called **before** the Controller is destroyed or the connection is closed — `Exiting->PlayerState` is still valid here. Do not defer cleanup to `EndPlay` on the controller.
- • The `FGameModeEvents::GameModeLogoutEvent` delegate is broadcast inside the base implementation. Always call `Super::Logout(Exiting)` to ensure plugins and online subsystems receive the logout notification.
- • During seamless travel, `Logout` is called for all players on the old GameMode before the travel completes, even though those players are re-added via `HandleSeamlessTravelPlayer` on the new GameMode.
Signature
virtual void Logout(AController* Exiting) Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| Exiting | AController* | The controller that is leaving the game. | — |
Return Type
void Example
Remove the player from a leaderboard on logout C++
void AMyGameMode::Logout(AController* Exiting)
{
if (APlayerState* PS = Exiting->PlayerState)
{
Leaderboard.RemoveAll([&PS](const FLeaderboardEntry& Entry)
{
return Entry.PlayerState == PS;
});
}
Super::Logout(Exiting);
} Tags
Version History
Introduced in: 4.14
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?