How much OnRep is okay?

I am currently syncing some functions with clients as some behaviors update frequently/‘spamishly’.
For instance, I have a function looping every 0.1 seconds, making a random behavior run. (could be moving an object, firing a particle etc.)
Each behavior also has a run count, so each time a function loops, it increments the running behaviors run count.

Clients request the run count, and server time in ms, so when they receive the server callback they can minus their own time in ms from
the server time, and calculate what the run count would be. It works really well, and behaviors run in sync regardless of ping.

I came to a problem though. If the server pauses/stops a behavior, it tells clients to pause/stop also. But if they have 400ms ping for eg.,
they can end up running the behavior more times than the server. (4x more if its a 0.1s loop with 0.4ms of lag). So I thought, I can always
reverse backwards, and easily tell what things need to be reversed but the client will see them behaviors for a moment.

I wanted this sync method because I don’t want to overload the server if I can get around it. Many looping functions could be running at a time.

So the main question is, I were to onrep the the object that was changed every 0.1 seconds, would that be considered silly? Or should I use what I have?
Thanks for any input.

If all clients need to be in sync, and it only happens once every 100 milliseconds, sending 10 broadcast events per second to tell the clients what should be run/happen seems totally reasonable. I don’t think you want OnRep for this, because OnRep is to replicate state (eventually consistent level) but doesn’t guarantee that you will see each event (edge transition.)

Thanks for the input, it maybe 10per sec in this instance, but there could potentially be 20 behaviors all doing things. t once. It’s essentially ‘sequences’ that do things at undefined times, for a random amount of time. I will keep thinking :slight_smile:

If 20 things each send 10 messages per second, they will all get aggregated into 10 separate network packets. As long as each message is short/small, that’s still not a problem.

2,000 things, each sending a short message, 10 times per second, OK, that’s where trouble starts :slight_smile:

1 Like

I figured hahah, I have looked so much on how RPC’s get sent on UE4, and in some tuts, the movement input events spam the server. So when a player holds down W, they are sending msgs to the server every frame saying so. I was thinking wayyyyyyyyy too much in to it.

Thanks :slight_smile: