Replication Question

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!

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.

Solution 1

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.

Solution 2

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.

Thanks, I ended up going to the Slacker Discord and got help there and it helped me understand what I was missing. Basically I didnt understand the concept of Actors being spawned at different times.