I am creating a modular npc system for my rpg game. How it works is the server has all of the npcs inside a table and then I use client side rendering to render all the enemies on the client. Each npc has a “RenderTime” which scales with how far the enemy is from the player (100 Studs = 1, 200 Studs = 3 etc…)
Then every 10 heartbeats RenderTime is subtracted by 1 and if RenderTime is 0 then I reset RenderTime and send the remote to the client containing Id, Name, Health, Level, Position, Target etc… I did a stress test and with around 200 npcs at once I’m getting around 90-100 kb/s and with the normal amount like 6 I’m getting 7kb/s standing right next to them. If you know any optimization tips please let me know!
Edit: The performance was a whole lot worse before I added the distance thing (300kb/s during stress test)
This probably happens because every single npc sends data to the server through a remote event every a bit of frames. ( For some reason i saw it was 10 frames )
Instead you could send all of that information in just a single event, and only send information that needs to be changed.
There is not need to send data that didn’t change.
Ah yes I see what your saying, not all of the data is being send every 10 frames as i explained in my distance thing. But I could refrain from sending data that has not changed, ill try this out and let you know the difference!
It works, I can have over 1000 npcs now while only having around 10-20kb/s most of the time! (Although it gets pretty laggy having 1000 models animated and stuff)