Less network traffic?

What am I trying to do here?
Working on a custom humanoid, and while trying to implement the MoveTo() function, I want to have the CFrame set directly in the server, and tweened for the client.

What is it am I trying to solve?
Currently, the MoveTo() splits the path into sections, tweening the npc to each, one at a time. However since there is combat, I need the CFrame updating on the server to be about 5 times a second to ensure liability.
However, this means 5 events fired each second to the client which builds up traffic.

Here comes the question, what other ways would I be able to achieve this without building up traffic?

1 Like

I’m not sure I fully understand what you’re trying to achieve with the custom humanoid–
but you could try using NetworkOwnership to allow the client to control the NPC?

Not sure if that works on Humanoids though.

Alright, so yes there are A TON of options here.

→ I will start you out with likely the simplist

-Create a input driven event movement system so that like when i press forward I am pulsing events out
---- The idea here would be to think that if i hold it down for say 1 second perhaps thats 10 pulses and each pulse you know exactly based on inputs where the player should end up based on the amount of pulses.
– By making this deterministic you ONLY need to ensure that the original position of the character is syncronized on load in
– From there you only need to traffic the event itself,
------ Events might be like “W” “W_D” “W_A” or you could ENUM them and keep them numbers like
enum.W = 0
enum.W_D = 1
enum.W_A = 2

you get the point then each pulse your going to send that event and the server is going to hear those and processes them on it’s own just in data while the player is moving.

Due to this you can, with strong reason, assume the player will BE where they should be.

And now you can base all your detections from the SERVER position and not the player position.

So even if the person unhinged their character and flew around or whatever, it wouldn’t matter the server does not percieve them there.

This will keep your traffic SUPER light, and you won’t even need to reset their position. AGain the whole point is that it’s deterministic and since roblox networking using events is Order ENFORCED and ensured to be heard ( outside of values they are different) then you dont even have to worry about ensuring the order of events just that they are head and how you processed them each time they happened.

Now without a BUNCH more effort and longer explination then i have time for here. You can make this very lag reseliant BUT

This system as it stands would feel fairly reasonable at up to rough 90 - 150ish ping. There are some other tricks that you would have to do if you want it more manageable at higher pings but when it comes to networking the scaling of difficulty for that gap is … SHEER at the least. Try to keep your detection for attacks and such as fuzzy as you can get away with, without the player going “WHAT?!”

Hope this helps

2 Likes

The Custom NPC is anchored, thus I can’t set the networkOwnership
And the custom npc is because for the mobs all I need is the moveto function and health. Thus it would be way more performance efficient to create a custom one.