Hello!
I need to create an NPC mob system that can support around 400 entities on the screen. I found it necessary to draw NPCs only on the client and move them there. The server simply assigns the target position.
For movement, NPCs I’m using Humanoid, with all states turned off.
I use Humanoid so that the mobs don’t crowd and merge into one small bunch.
So, I need behavior like this:
Unfortunately, I could not achieve the goal. Because, ~150 mobs can be used without loss of productivity.
Therefore, I would like to know if it is possible to somehow optimize this system?
Humanoid is very unoptimized. You should create your own custom npc logic - it helps if the tasks your npcs need to do are relatively simple.
Some other optimizations:
Disable physics if you don’t need them (cancollide, cantouch, anchored models)
Core manager: don’t use a script for each entity, manage them all from one.
Try only moving the NPC models while they are on screen (you can check with raycasts)
Only tell client to mimic NPCs that are within a certain radius, so you don’t need to simulate the entire map
400 entities is a lot! Are you sure 150 is too little? At worst, you could try grouping entities into one - so each model actually represents 4 entities, for instance.