Last active
January 15, 2023 17:28
-
-
Save gamerxl/1b8e7dea36f6d876c09b13b0866897d7 to your computer and use it in GitHub Desktop.
Travel to server default map during game init (GameInstance) from c++ in unreal engine. You can get or set the server default map below "Maps & Modes" in Project Settings.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Example how to travel to server default map during game init. | |
// Use a custom game instance and override method Init from UGameInstance. | |
void UCustomGameInstance::Init() | |
{ | |
Super::Init(); | |
if (IsDedicatedServerInstance()) | |
{ | |
FString ServerDefaultMap; | |
GConfig->GetString( | |
TEXT("/Script/EngineSettings.GameMapsSettings"), | |
TEXT("ServerDefaultMap"), | |
ServerDefaultMap, | |
GEngineIni); | |
FString URL = ServerDefaultMap.Append("?listen"); | |
UE_LOG(LogTemp, Warning, TEXT("UDefaultGameInstance::Init: Travel to %s"), *URL); | |
GetWorld()->ServerTravel(URL, true, true); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment