I have an actor placed in world.
The actor spawn a Niagara System loop.
When the map is loaded only the host can see the first loop.
Clientes can see the second loop too.
This man says about to use multithreads to wait for levels loaded (min 7:15) (FAsyncTask)
He says that when the level is loaded you receive a notification.
Is this the solution?
Can someone provide an example of this please? (C++ or BluePrint, everything is fine for me)
If the clients aren’t seeing the first spawning, then they aren’t loaded enough to receive and process it. After the Switch has authority add a 2 second delay.
But… It is going to work in a real scenery?
I mean… the loading time could be different depending of the kind of CPU, RAM, SSD, bandwidth…
So it may be that a client takes more than two seconds to load.
How can I handle this situation?
I mean, is there a way to synchronize the start of the game when all the client machines have loaded the map?
I understand what you mean.
In some cases that is the best solution (do not replicate it).
But in this specific case I am interested in all clients seeing exactly the same as the server.
It is not a cosmetic particle system. It does critical things for the game.
Furthermore, I think it is an excellent example that shows very well the problem of loading maps and synchronizing players.
I want to learn to handle it correctly. I think it is something very basic and fundamental in a multiplayer game.
this thing is, itll never be truely in sync with the server, even if you start them at the same time the multicast will take a delay to execute, ie lag.
otherwise, have the client tell the server its loaded in an RPC then when all clients are loaded send the multicast
Hence the polling recommendation. Even then you still won’t get proper sync. Servers will always be ahead of clients. Clients ping differences will always desync client to client views of the game world.
Furthermore, FX shouldn’t be played on the server. It’s a waste. They don’t render anything, nor play audio.
Thank you very much for your answers @Rev0verDrive and @Auran131
I guess the problem now is knowing when the clients have finished loading.
(Knowing how to do the client polling setup).
You are right, in the case of a dedicated server the FX does not need to run on the server. But if the host is a player then it is necessary.
The problem seems to be more complex than I thought.
Any information on how to do the client polling setup is welcome.
Something like this? This seems to work…
However, I’m not sure if it works because of the timer or if this is really the way to do it.
I would like to do it without the timer but I do not know how.
you could set the expected number of players in the game instance. you’d likely know this before you load a map/gamemode. obviously your timer will fail if they take longer than 3 seconds.
Thanks a lot for your help @Auran131
And @Rev0verDrive thanks a lot for your help too.
Without the help of you two I would be very lost in this matter.
I would like to accept all your answers as a single solution.
This is a dilemma!!
Maybe a moderator reads this and knows what to do in these cases.
This isn’t telling the GM that the player has loaded their world (map). It’s just counting connections.
When we connect to a server it creates a controller. The GM then spawns the pawn assigned in the settings then the possesses it with the control. The pawn is then replicated. At the same time we are getting world information and starting to load the map on our end. Reality here is the pawn will load and start falling before the map is ever ready. This isn’t an issue on simple content example maps, but full production ones it is.
What’s needed is a way to have the pawn notify the GM when the level is loaded on their end. The way I do this is with a barebones pawn class set as the default in the GM settings. When it determines the level is loaded it calls it RPC’s the server controller which calls the GM to swap out the loading pawn to the actual character.
The swap point is where you’d want to do the counting.
BP_LoadingPawn is the base Pawn class. No input, no mesh, no movement.
For simplicity the code shown does a simple delay then calls the controller event. In production you’d have code to determine if your level was sufficiently loaded in order to spawn the main character without it falling through the map.
For clarity I should note that most production levels have a 15 to 30s+ loading time. Sometimes its drastically longer, but that depends on the clients hardware and the overall performance of the level.
I prefer checking for the existence of specific large actors inside a radius of the player. I also do line traces downward checking for ground underneath the player.