Create players on the fly

Hey,

as you already figured out, the LevelBlueprint is called once per NETWORKED Player.

To not have misunderstandings:

  1. Networked Player: Lan, Internet
  2. Local Player: Players on the same Computer / maybe Splitscreen

Each Player needs a valid PlayerController to be correctly represented. The initial Player, the one you get with simply starting the game with the PlayerNumber Setting at 1 already has a PlayerController.

The PlayerNumber Setting is for Networked Players. If you set it to 2+, it will create a LAN Connection. This has nothing to do with Local Players. Keep in mind, that the GameMode only exists on the Server. If you add a Networked Player to the setup, he will NOT call the GameMode functions (if he’s the client).

Split UI from Logic!

Always remember: UI is meant to display information and not to handle logic!

This means, you should not let your Widgets Listen for the Controller Input.

Spawn your Widget at a place where you can access it (not the LevelBlueprint). For example the GameMode or GameState. Now let the PlayerControllers listen for their own Input and if you notice an Input, just set a Variable in the PlayerController. Let the Widget only GET data from the each PlayerController and display it.

tl;dr Version:

  1. Spawn Widget in a class you can easily access (GameMode/GameState) You never know, if you need it again!
  2. Let the PlayerControllers listen for Input and set a simple Boolean for “Joined” or something
  3. Let the Widget get each PlayerController and display information, based on the Boolean or what ever you want to use

Adding a Networked Player to the Local Game

To be honest, I’ve never done this. I actually also have never worked with LocalPlayers. I only work with the Networked stuff. But you need to adjust your logic based on the following information:

  • Networked CLIENTS don’t have a GameMode.
  • Networked CLIENTS only have their own PlayerController
  • Networked CLIENTS use the replicated GameState (PlayerArray) and PlayerState to share information about the current State of the Game and Player (minus PlayerCharacter stuff, like Health. That’s managed in the replicated PlayerCharacter)
  • You may need to manage Local Clients and Networked Clients differently, since I don’t know if each Local Client gets a Replicated PlayerState for the Network Session

All in all, as soon as you add Network to it, you need to follow the Networking rules of replication.

I hope that helps to get started!

Cheers!