RealDocs

AGameModeBase::ReturnToMainMenuHost

function Engine Blueprint Since 4.14
#include "GameFramework/GameModeBase.h"
Access: public Specifiers: virtualUFUNCTIONBlueprintCallable

Description

Disconnects all players and returns the server to the main menu map. Used to cleanly end an online session.

Caveats & Gotchas

  • This calls `ClientReturnToMainMenuWithTextReason` on each connected player controller, which triggers a client-side travel — all connected clients will be kicked with a disconnect reason before the server travels.
  • The function only exists and has effect on the server; calling it on a standalone game will still work, but for listen servers all remote clients are disconnected first.
  • There is no confirmation prompt — the transition begins immediately upon calling this function.

Signature

ENGINE_API virtual void ReturnToMainMenuHost()

Return Type

void

Example

Return to main menu after all players leave C++
void AMyGameMode::Logout(AController* Exiting)
{
    Super::Logout(Exiting);

    if (GetNumPlayers() == 0 && GetNumSpectators() == 0)
    {
        ReturnToMainMenuHost();
    }
}

Version History

Introduced in: 4.14

Version Status Notes
5.6 stable

Feedback

Was this helpful?

Suggest an edit

Select a field above to begin editing.