Hi, can anyone help me with this? i set 23 collectibles on gamemode - on server it will spawn 23, but client will spawn only 8,…everytime i try to play game, value on client its different,…but its funny, bcs it worked when SPAWNACTORS were very close too each other, then i put them little bit away and got this
Are you not seeing all 23 spawned BP on the client or is it just the replicated variable?
Try this in your player controller to make sure.
The begin play may get called in the controller before the game mode is finished spawning.
You should only set replicated variables on the server or they could get out of sync.
And replicated variables sometimes take several frames to complete replication.
so i tryed this method and it always double it on client,…but atleast its not random number
Can I see the change you did in the blueprint?
The ClientCollectibleCount is zero
And the ServerTotalCl printed twice and the number is different on the server.
I ran this code in my testing blueprint with my pickups and got this result in the log.
ok so i tryed something even much i dont know what, but for now its working :DD, anyway thanks here is solution :
Will the game have a dedicated server or just a listening server and a client (or more than one client)?
Just want to point out a few things about networking.
The player controller only exists on the server and the owning client. So the server will have a copy of all the player’s controller, but the client will only have their controller on their machine.
If there are three players
Player 1 (listening server) will have all three controllers on their machine.
Player 2 (client) will have their controller on their machine but not Player 3’s controller.
Player 3 (client) will have their controller on their machine but not Player 2’s controller.
So a client can not access another client’s controller.
The character/pawn and actors will exist on all machines.
If the variable TotalCl is something that all controllers need access to, it should be in the GameState (exists on server and all clients), GameMode (exists on server only, so it don’t replicate anything).
The GameMode could spawn the actors.
The GameState should hold the replicated variables, and it could also spawn the actors instead of the GameMode as long as the server is doing it.
The the client’s controller can access a replicated variable from the GameState.
Also I see your using a MultiCast Event to spawn.
Spawning actors, setting replicated variables, and DestroyActor should always be done on the server.
Actor’s Replication Settings:
NetLoadOnClient=true should make a copy of what the server spawns on the clients.
Replicate=true will allow variables to replicate in the actor blueprint.
alright thanks for tips! i really appreciate this
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.