I am working on multiplayer since 1Y+ and I achieve what I want and think I understand the whole concept about replication/multicast/run on server/repnotify, etc…but then sometimes things are not working and I start trying different approaches and then It works and I say aha! this is how it works and I am in that cycle forever…I never fully understand everything about replication and multiplayer.
Right now I want to run a multicast event from a widget event (lets say a key press).
I dont know what is the situation where runOnServer–>multicast works doing all inside player controller and when I need to do runOnServer(PlayerController)–>multicast(Gamestate)
Can someone explain? I am not looking for a solution here…just looking for answers and try to understand for once.
You should not use player controller. It is not spawned on the server.
Instead of GameMode use GameState, instead of PlayerController use Player State.
Try that one, and let me know how it works. I used it widely on my game, and every type of event replication worked consistently.
Because like I said, player controllers only exist on the server and their owning client, so a multicast won’t work as you want it to, since the other clients dont have your player controller, so the multicast will never reach them
No they don’t . They were null on my game. Either I missed something really big, or I have developed my game in really wrong way :D. I used playerStates.
Player controller only spawns locally on the local player controller.
@zeaf is correct. PlayerControllers are Spawned by the Server but only relevant to the Owner and therefore any replication on playercontrollers only reach the owner.
Ah OK. Understood. This is why I had them as null then. It explains it. Anyways, we all agree, for replication stuff we should use PlayerState?
Sorry @zeaf
Rules are pretty much the same in every replicated component. It really depends on what do you need. Do you understand difference between Client, Server and Multicast?
Yes I do. But I assumed as player controller lives in the server and the client then lives in all the others but now is clear all playercontrollers are replicated only on owners and server
you just have to remember the point of both objects
A player state is meant to contain data and functionality specific to the player, whereas a gamestate is meant to be for the “game” itself
Each player has ownership over its own player state, which means they can call Server RPCs from it
The gamestate is owned by the server only, so no player can call Server RPCs on it (unless the server has a controller, which is the case for Listen Servers)