Team Setup, UMG Widgets, Spectator mode (all-in-one problem!)


I’m having trouble setting up a basic “team selection menu” upon player connecting.
Here’s what I did:

First, I added [FONT=Courier New]bStartPlayersAsSpectators = true to my GameMode constructor. I learned that it isn’t working on Play-in-Editor. Not sure about listen servers. I filled a bug report here. I would love a temporary workaround for this.

Then I added a simple, two teams button widget blueprint.

After that, I tried to set it up with the code:

	UUserWidget* WidgetInstance = CreateWidget<UUserWidget>(NewPlayer, TeamSelectionMenu);
	if (WidgetInstance)

Initially, I thought it would be a good idea to add that to [FONT=Courier New]MyGameMode::StartNewPlayer(APlayerController* NewPlayer), but then I noticed that this runs only on the server (so it only appears on the listen server). I don’t want to make that run via blueprinting.

So, my issues are:

1st) Is there a workaround to make players spawn as spectators, even on listen servers? (BONUS: Be able to set the player location as soon as he spawns - thought I can probably move the player to a friendly “Player Start” once I get it working)
2nd) Where should I add that piece of code (or something similar) so that, once the player connects to the server or enter a new map, it creates and display the UMG widget, so the player can choose the team he will join?

Thank you in advance! :smiley:

Look into RestartPlayer() inside GameInfo. That’s what controls all the spawning logic. There is also I a PreLogin() and Login() functions inside GameInfo that can contrl whether a player can join, and what to do with them once they join (which calls RestartPlayer() if they’re good to enter the game).

As for the rest, the modifications you’re making, which all those functions given above will run on the Server and not the client, you can then use it call Client Functions on the owning client to open the menu on their end.

Thank you IrishKilter!
I was missing the client function to make everything work!

Also, everything else might be solved when this is solved: