How can I change the level in a multiplayer game and how can I add a loading screen?

Hi, I’m making a multiplayer game, but I need to change the level during gameplay and add a loading screen. How can I do that?

1 view?

If its a multiplayer game and you are moving things to a new level you need to make a seamless travel setting up the transition map.

Travelling In Multiplayer

Simply on the new levele you can spawn a new hud and display loading screen over there till everything is finished. Since its multiplayer depending on the game and how its played would many things as you know show a progress bar or just make it static depending on the experience required.

-Sometimes game start when all players connect
-Sometimes there would be a large load operation of the new map.
-Sometimes some objects will exist on the new map (atleast players)
-Connection checks, security etc. list is long.

So you can do all these things after going to Transition Map and keepin connection alive

1 Like

Game Mode → HandleStartingNewPlayer

Called after PostLogin or after seamless travel, this can be overridden in Blueprint to change what happens to a new player. By default, it will create a pawn for the player.

PostLogin is only called on the initial server connection.

Game Mode Class

Controller Class

1 Like

Forgot to mention that by default Handle Starting New Player is what spawns the pawn and possesses it. If you’re relying on that functionality then use On Restart Player.

As soon as the Pawn is spawned and possessed this event is called.

GameModeBase.cpp

void AGameModeBase::FinishRestartPlayer(AController* NewPlayer, const FRotator& StartRotation)
{
	NewPlayer->Possess(NewPlayer->GetPawn());

	// If the Pawn is destroyed as part of possession we have to abort
	if (!IsValid(NewPlayer->GetPawn()))
	{
		FailedToRestartPlayer(NewPlayer);
	}
	else
	{
		// Set initial control rotation to starting rotation rotation
		NewPlayer->ClientSetRotation(NewPlayer->GetPawn()->GetActorRotation(), true);

		FRotator NewControllerRot = StartRotation;
		NewControllerRot.Roll = 0.f;
		NewPlayer->SetControlRotation(NewControllerRot);

		SetPlayerDefaults(NewPlayer->GetPawn());

		K2_OnRestartPlayer(NewPlayer);
	}
}

GameModeBase.h

/** Implementable event called at the end of RestartPlayer */
	UFUNCTION(BlueprintImplementableEvent, Category=Game, meta = (DisplayName = "OnRestartPlayer", ScriptName = "OnRestartPlayer"))
	ENGINE_API void K2_OnRestartPlayer(AController* NewPlayer);

2 Likes

Thanks for answers!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.