I recently have been looking into making a custom humanoid solution to handle lots of NPCs in a condensed area, all of these NPCs would be moving a lot and likely pathfinding. I aim to have 250-300ish NPCs without lag but I could probably get by with 200.
The main issues I’m running into are just conceptualizing how a system like this would work at a technical level. My current idea is to have a root part on the server that controls position/state and then animate and render clientside. The issue with this I can’t figure out how to solve is keeping the positioning the root part above the ground while also allowing for movement. My first idea was to just raycast downward at the X and Z coord the part is at and position off that makes it hard to do things like jumping, I could possibly tween the offset from the ground but tuning it to look exactly like a normal jump sounds not possible.
my next issue is about movement. I see a wide variety of solutions other people have used to move a custom humanoid. Some use lerp, some use tweens, some use BodyMovers, etc. The simplest solution I can come up with is just changing the root parts position on the server but doing that every heartbeat for ~250 parts sounds extremely inefficient. Maybe I update less often and compensate on the client, but then that makes my NPCs teleport around if the direction they are heading in is suddenly changed.
My final question is about pathfinding: obviously pathing for 250 NPCs individually isn’t possible. The issue I face is that my map isn’t dynamic so I can’t create a flowfield or node system to help path. My game centers around the players being able to build defenses to survive NPCs, the base game is almost completely flat and objectless but players can very easily build massive and complex structures. I don’t know how I can pathfind around these.
overall I’m pretty stuck and would appreciate any help I can get. Thanks!