I hear that if I want to make my game to support a large amount of NPCs, using the Roblox Humanoid Class would be very laggy.
Let’s say I want my game to support up to 100+ NPCs with can follow, attack and other zombie like features plus after optimization, would I be better off making my own “Humanoid” than using Roblox’s?
Yes, not using roblox humanoids would be a good way to reduce lag.
Restaurant tycoon doesn’t use humanoids in the npcs. It uses body velocity to make them walk, and I made my own MoveTo function with the body velocity, but this wouldn’t be so easy for more complex maps if you have hills and stuff.
Think of a human as a humanoid you can improve on it if you change it to your standards. But if you want the plug in I don’t belive it would work with a custom one. Also it probily can’t run a animation that wasn’t made for the custom humanoid.
A custom humanoid is essentially writing an agent class in Lua. While you can optimize a lot by only creating the functionality you need, if you end up re-writing most of what Roblox humanoids do you are going to lose a lot on the performance end as most (if not all) logic you use is in the Lua side. It is a bit of a trade-off; do you scrap enough functionality to beat Roblox’ built in Humanoid or do you need to re-create too much to really have a positive performance impact.
Sorry if this is a bit off topic, but you could always calculate the distance between player and zombies, and ones that are too far away, from any player, just despawn them. And if a player has x amount of zombies already chasing them, then new zombies will stop chasing, and again, once they are out of range, they can despawn. Perhaps don’t even spawn new ones in a players location if there are x amount chasing them. Just something to think about.
So, I’d also like to create custom humanoids, but for players instead. How would I make custom HipHeight and HumanoidStates? Those are the only things I need, apart from making it work with the default control scripts, but I don’t know if that is possible.
Usually, the lag “caused” by Humanoids is more or so the developer’s fault for not optimizing their code correctly. If it was the Humanoid’s fault, you wouldn’t be able to spawn in multiple humanoids (without coding.)
It’s best to write a custom NPC script, than to use a free model one [ as most are CPU hogs] , and optimize it, as @SelDraken has stated.
Running humanoid functions in Lua might also be the complete opposite of what you’re wanting.