This is the Event Graph of my player controller. The Goal is that the Server spawns a button to start the game. I tried to use the “Switch has authority” so only the server executes the spawn.
The problem now is that the button gets spawned 2 times when 2 clients are connected. And 3 times when 3 clients. And so on. How do get the spawn only to execute once for the server ?
In my understanding the Server has its own playercontroller and the playercontrollers of the clients. But only the server playercontroller has authority. So it should only execute to top path of “has authority” once.
But only the server playercontroller
has authority
No, server has authority. For example if you have listen server and two clients, then you have 3 player controller on the server for all of which the server will execute EventBeginPlay. Since server has authority it will execute the Authority branch.
What you could do, is to check authority and local controller (so that only the local controller executes that code). Or put the code somewhere where only the server executes it (e. g. GameMode).
Ah ok, with a dedicated server there is no player controller for the server so that’s why it doesn’t execute. So you cannot have that code in the player controller, you need to do it from somewhere else (e. g. GameMode, LevelBlueprint).