Merge pull request #30 from uno1982/master

Add server travel blueprint node.
This commit is contained in:
Joshua (MordenTral) Statzer
2022-03-11 13:40:23 -05:00
committed by Joshua
parent aee6c013d6
commit 707c055f49
2 changed files with 17 additions and 0 deletions

View File

@@ -199,6 +199,12 @@ public:
// Checks if the stated session subsystem is active // Checks if the stated session subsystem is active
UFUNCTION(BlueprintPure, Category = "Online|AdvancedSessions|Misc") UFUNCTION(BlueprintPure, Category = "Online|AdvancedSessions|Misc")
static bool HasOnlineSubsystem(FName SubSystemName); static bool HasOnlineSubsystem(FName SubSystemName);
//**** Seamless travel Functions ****//
//Exposes Server travel to blueprint
UFUNCTION(BlueprintCallable, BlueprintAuthorityOnly, Category = "Online|AdvancedSessions|Seamless", meta = (HidePin = "WorldContextObject", DefaultToSelf = "WorldContextObject"))
static bool ServerTravel(UObject* WorldContextObject, const FString& InURL, bool bAbsolute, bool bShouldSkipGameNotify);
}; };

View File

@@ -528,3 +528,14 @@ void UAdvancedSessionsLibrary::GetNumberOfNetworkPlayers(UObject* WorldContextOb
NumNetPlayers = TheWorld->GetGameState()->PlayerArray.Num(); NumNetPlayers = TheWorld->GetGameState()->PlayerArray.Num();
} }
bool UAdvancedSessionsLibrary::ServerTravel(UObject* WorldContextObject, const FString& FURL, bool bAbsolute, bool bShouldSkipGameNotify)
{
if (!WorldContextObject) return false;
//using a context object to get the world
UWorld* const World = GEngine->GetWorldFromContextObject(WorldContextObject, EGetWorldErrorMode::ReturnNull);
if (!World) return false;
World->ServerTravel(FURL,bAbsolute,bShouldSkipGameNotify);
return true;
}