Im very new to networking and Im struggling with the logic of how Replication works.
My main question is how does this not print the ints on every client?
My understanding is that the SERVER will collect the Random Ints and then I can tell all of the clients to print this number passed by the RPC, am I missing something basic or is this a bug? Thanks in advance!
asked May 07 '19 at 08:42 PM in Blueprint Scripting
Replicated Actors are first spawned on the Server and then Replicated/Spawned on the remote clients. The Server can't send the RPC (Multicast) before the Client has spawned the Actor. This is why nothing happens when you call the RPC on BeginPlay.
Make a replicated variable set to "Instance editable" and "Expose on Spawn" and have the Server use SpawnActorOfClass and input the variable into the SpawnActorOfClass node. This will ensure that the clients will spawn the Actor with the variable already set.
Instead of using an RPC (Multicast) set the value in a variable set to "RepNotify". Then the Clients can print the variable in the OnRep_ function. Replicated variables might skip intermediate values as it only sends the latest value if it can.
answered May 07 '19 at 10:15 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here