I am working on a project that needs to replicate a struct array to the client. The Array only has raw data (Vectors, floats, ints, etc).
I set the array to be replicated (also tried RepNotify), and everything works in the editor (tested with multiple clients).
But when packaged as a build, clients sometimes can’t get the array (array length 0).
Currently, it seems this happens more often when the host is a slower machine.
Any idea how to force the array to be replicated? It’s not a big array (around 600 integers), and it only needs to be updated once every session.
Hey there @SimbaDdsa! How quickly after are you checking the client changes? Variable changes with RepNotify are relatively reliable without any missing packets. Generally I try to keep logic that relies on server data on RepNotifies, as that should trigger the frame the data is actually updated.
Is it just missing the data entirely sometimes? How consistent is this to reproduce?
Hi, Thank you for the reply.
Originally I was afraid of the same thing so I set a few seconds delay on the client side, but to no avail.
So I then set a Print Array Length on the client on Tick, and that’s when I saw it’s a consistent 0 on the client no matter how long afterward. I kept the game running for a few minutes, and the server was printing 512 correctly.
Also since the client never got the correct data, RepNotify never fired on the client.
It’s not consistent though, randomly happens, and more often when hosting on a slower PC.
Based on our current test results, it’s about 70% - 90% on a slower host(My bad PC), and only about 1% - 10% when hosting on the fast one.
This problem happened on three BP actors in our game. All of them are placed in level and loaded through sublevel stream. Each sub level will only contain 1, actors were all set to AlwaysRelevant.
We are using ReplicationGraph in our project and the base actor is correctly added to the graph as AlwaysRevelantClass.
So we have found a way that solve our current situation: instead of pre-placing the actor in the level/sub-level, spawn it dynamically from the server side.
Still not sure why, but seems the actor replication connection sometimes fails for existing actors in the level.