Hello everyone!!!
So I was working on a NPC system where the simulation happens on the server but is not replicated onto the client automatically. I pack data and then send the data to all the clients. Then the client script uses this data to create a new NPC rig from replicated storage with all the positions and CFrames updated. This is then paired with a “server tick” which sends and packs data through a specific increment (0.3 seconds right now).
However, the limit that this system can hold is around 2-3 NPC before the payload (data) is too large.
Now this is after I trimmed down the data a lot more: I split up vectors, etc.
I kept CFrame’s in its original state because I don’t know how much more optimal it is to send raw numbers over it (any suggestions or feedback on this is appreciated as well)
CFrame for determining orientation of NPC could be replaced with single angle rather than storing all that info. Playing animations is too much, you can store all your animation info in a module that client can access, or you can just directly group all your animation into one folder and use it as source of animation, if you need walk animation go clone one of the animations stored in there. Don’t use animationId for determining what animation npc is playing, if your game has 100 unique animations its better to give each one id from 0-100 or 0-255 (because this is unsigned 1 byte int) instead of using larger data type for long animation ids. 6th data is also expensive, either remove them from data structure or replace them with angles (a number not vector3). 7th data can use similar technique I recommended for animations and actually should use.
You also should learn how to construct data buffers and learn what they are.
Thank you for the insights! May I also asked if bitpacking can help? And how optimal is it (pros/cons if possible). I heard bitpacking is something many games use to handle a lot of NPC simulated data, but I never really used it before, is it worth implementing?
you bitpack booleans, and if u really have alot, then it can definitely help, even 8 booleans packed into one byte is good for optimization
u need to know how it works
by default boolean in binary is stored as 00000000(false) and 00000001(true), by this u can clearly see that that last bit on the right is what the value of a boolean is, true or false, and u see 7 zero bits are unused, meaning, u can pack 7 booleans into those slots