Hi, I’m making a basic multiplayer game with character selection. In th lobby the player selects a button which sets the character class to be spawned. Then in the level blueprint the game instance calls a function which unposses, destroys the current player and then spawns the player, however this is only working for the server player not the client player. I have checked that the character class is getting passes through correctly, meaning he character does not get spawned at all, why is this?
The code thats spawns the player:
APlayerController* PlayerController = GetFirstLocalPlayerController();
if (PlayerController != nullptr)
{
PlayerController->GetPawn()->Destroy();
PlayerController->UnPossess(); // Unposses anything already in play
PlayerController->SetInputMode(FInputModeGameOnly());
}
ABaseCharacter* Player = GetWorld()->SpawnActor<ABaseCharacter>(CharacterClass); // Spawns actor depending on class Selected
if (Player != nullptr)
{
GEngine->AddOnScreenDebugMessage(-1, 200, FColor::Green, TEXT("Player is being spawned"));
PlayerController->Possess(Player); // Posses the character
PlayerController->SetInputMode(FInputModeGameOnly());
}
else
{
GEngine->AddOnScreenDebugMessage(-1, 200, FColor::Green, TEXT("Player is not being spawned"));
}