Any optimalization tips? (Managed about 1500 NPCs mostly without lag.)

I don’t think it’s the parts mainly.
Mainly physics and hit boxes/touch events that make it laggy.
I was wondering…
Is there a way to turn off the touched event for parts so NPCs touching each other won’t trigger it?
But players and ray-casts hitting the parts should still work.
I could do a lot with that knowledge.
I’ve heard of collision service but never used it before in all honestly.
Even my current 1K AI game doesn’t use collision service.
The NPCs quite literally just use a few parts and a lot is rendered client side. Touched events are still triggered when they hit each other.

3 Likes

Have you tried shifting network ownership of npcs close to players?
It could take some of the physics load off of the server, since the players would be handling physics instead of the server.

I haven’t thought about that actually.
But wouldn’t this result in really choppy movement if the NPCs target suddenly switched on a laggy server?
But I’ll keep this in mind, thank you, perhaps this could help a lot in games
that need to handle a lot of zombies at once.

If I can make a full functional, hyper-optimized zombie AI
and have 2000 zombies walk around I could perhaps make a game
like Deadrising in Roblox.

I’d be cool to have players literally bulldoze through tons of zombies with vehicles or weapons, I’m pretty excited about that idea.

4 Likes

hello, can you share what you did?

I recommend adding an LOD system (Total war games), as player doesn’t need to see all the NPCs, only a fraction of them. What you could do is create “Squads” where you load the NPC data into some array and when player gets close enough or will see the “Squad” soon enough just load it back in. The squads are NPC in themselves but are invisible to the player and have no reference in the world space, but they also move in it. This will allow for much larger simulations and could be useful in other projects where there are huge battles between thousands of units.
Also adding max AI decisions per tick is a good practice too (Ravenfield uses that)! You basically iterate over some value of NPCs per heartbeat and make decisions for them and then wait for another heartbeat so the cycle can repeat but on other zombies. Of course you have to iterate over all of the NPCs but this change itself will make up for the performance. You can also set priority of those AI units based on how close they are to the players. Roblox has also special function called BulkMoveTo, you really should check it out as it can improve the performance even more.

1 Like

So do you run animations if the client is looking at x zombie only?