Download

UE4 Server spawns 2 PlayerControllers for himself. This is driving me crazy, please help

As title says, when I use the editor to run the game with 2 players (no dedicated host), the PlayerController’s BeginPlay triggers twice for the server, when I check the PlayerController’s display name it shows 2 diferent names like PlayerController1 and PlayerController2, and the client gets PlayerController3

While the game is running, I go to the WorldOutliner, and there are only 2 PlayerControllers!

I don’t understand why the Server would create 2 PlayerControllers and then just keep one, I can’t find the logic on that, nor rely on it to create Timers :<

There are multiple copies of objects created. One for each client, and then for each client on server.
Yeah well, debugging it might not be the easiest thing in the world, but all I can say it’s still pretty easy, and you will just get used to it.

Thank you for the quick support, I really appreciate it.
I have been debugging for the past hours and have looked on the web, there is something I must really be missing,

After several tests I see the Host have a copy of the PlayerController for each Client, but also for himself,

Is there a way to know inside the PlayerController blueprint, if that event running is running as a copy ?
OR do I have to rely on the Get Owner’s display name? (Server1,Client1, etc)

I dunno how to do it in blueprint but in code I usually just check network role, to see if object I’m looking at, is server or client version.

I guess you could setup something similar in blueprint.

Use the HasAuthority switch, it will allow you to have different behaviour depending on if the class is executing on the server or client side. Also note that this one doesn’t work that good on a Listen server, it seems to get confused in that scenario.

Server will have all the player controllers in game where as Clients are only aware of their own player controller. While playing the game, open your Player Controller Blueprint and on the toolbar you can filter by Server and Client. Here are two screenshots. First one is Server and it shows all the Player Controllers. Second one is Client and it only shows its own Controller.

Server.png&stc=1

Client.png&stc=1

The Server PC will have PlayerControllers’ BeginPlay triggered twice because he owns his PlayerController and he is the server.
If I use HasAuthority it will always be True because he is the server.

How can I know if BeginPlay is being triggered as the PlayerController copy of himself?