hello i have three stage in my online multiplayer . menu->lobby->game. in menu, player choses character and hosting or joining. then they travel to lobby. in lobby everything is correct but after this when they travel to game there are just cameras in wrong location and I cant control it.
#include "LobbyMyGameMode.h"
#include "GameFramework/GameStateBase.h"
#include "TimerManager.h"
void ALobbyMyGameMode::PostLogin(APlayerController* NewPlayer)
{
Super::PostLogin(NewPlayer);
// Count the number of players currently connected to the server
int32 NumberOfPlayers = GameState.Get()->PlayerArray.Num();
// Log the total number of players for debugging purposes
UE_LOG(LogTemp, Warning, TEXT("Player joined. Total Players: %d"), NumberOfPlayers);
// If the required number of players is connected (e.g., 2)
if (NumberOfPlayers == 4)
{
// Start a 5-second timer before initiating seamless travel
GetWorldTimerManager().SetTimer(
SeamlessTravelTimerHandle, // Timer handle
this, // Object owning the timer
&ALobbyMyGameMode::StartSeamlessTravel, // Function to call after the timer
5.0f, // Timer duration in seconds
false // Do not loop the timer
);
// Log the start of the timer
UE_LOG(LogTemp, Warning, TEXT("Starting 5-second timer for seamless travel."));
}
else
{
// Log if waiting for more players
UE_LOG(LogTemp, Warning, TEXT("Waiting for more players to join..."));
}
}
void ALobbyMyGameMode::StartSeamlessTravel()
{
UWorld* World = GetWorld();
if (World)
{
// Enable seamless travel to avoid resetting game state between levels
bUseSeamlessTravel = true;
// Log the transition to the new map
UE_LOG(LogTemp, Warning, TEXT("Starting seamless travel to game map..."));
// Initiate server travel to the specified map
World->ServerTravel(FString("/Game/Maps/PanchaMap?listen"));
}
}
thats my lobbygamemodeclass lobby gamemode bp is based on this class and panchagamemode is based on Gamemode
it was collision problem character was spawning inside mesh or smth. I just move down whole map and it works as intended
1 Like
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.