Hello.
Did anyone had this problem or bug?
I work on lobby menu. In my **GameMode ** in event OnPostLogin i add new connected player to array **AllPlayers ** - in this array all player controllers
After that in my player controller i start function PCSetupLobbyMenu which is create lobby menu(widget) on connerted client. Function type - Run on owning client
After that i use function GMUpdatePlayersListInLobby (run on server), this function are in GameMode.
Function GMUpdatePlayersListInLobby
In this function every player controller run function PCUpdatePlayerLists (Run on owning client).
In this function i get GameState and for each element in GameState->playerArray i create widget add it as child in my PlayerList Widget.
All works, but works only with delays
I use delay in PlayerController->EventBeginPlay 0.1 second and in PlayerController->PCUpdatePlayerLists - 0.3 seconds
It doesn’t work without delays because when PlayerController->EventBeginPlay GameState doesn’t exist on client.
Am i right or problem in something else?
How to fix that and work without delays?
Anyone know in what oder UE4 create classes and start game?
Use of delays is very common with mutliplayer games.
This is because the server has to process and determine information for replication, then… because of widely varying network and client system performance; you have no clue how long it will take before clients are aware of new data.
One thing to be careful of, is the Sequence Node. It’s not just a simple organizational tool for BPs that says, run this first, and when it’s finished, run the next…
It fires them all off (almost simultaneously).
It’s useful when you have a long chain of sequences you need to run, but don’t depend on each other.
So, if you have sequence 2, but it relies on information/action performed in sequence 1… don’t separate them.
Depending on logic and what is being accomplished, you can control flow and functions via delays, Server/Client/MultiCast Events, and/or “On Replicated” functions to take action when something has replicated new information.
For example, it is handy if you have a replicated variable on the server (like Action X has happened)… Instead of firing off events or functions to clients that may not have that new variables information (without using a delay)… Have the clients perform the action themselves via a local run function that is initiated when the variable replicates down the new value.
For Example:
Variable A is boolean, and replicates with notify.
The client has a function “OnRep_A”
That function says, if A = true, do blah…
That may not apply to your scenario here, but perhaps it will spark an idea on your current approach.