I have been designing a simple zombie game recently. But I have now come across various questions on how the zombies would operate. The game is a building defense game and zombies will break walls and attack players.
But the original Idea I had for a script turned out super not optimized for the fact that there will be a max of 200 zombies constantly on the map.
The script currently makes the zombie travels in a direct line to the player using Humanoid:MoveTo()
What would be the most optimized Idea for zombies to be able to detect when they are in reach of a player to attack and when there is a wall to break that’s stopping them from reaching the player?
Im looking for script concepts and ideas, not full scripts
The only problem with it is that it’s a little performance heavy. Zombie rush uses MoveTo but that’s not really a problem for them if the zombie is blocked.
Yeah I know but im not asking for a script to move the zombies. I simply need ideas on how to make it optimised for them to detect when they are near enough of a player or a wall.
I taught about a region3 with :GetTouchingParts()
or a humanoidRootPart.Touched() but both arent really optimised because they constantly check for every single part they touch.
There was this module that makes it really easy to get an event of when a part reaches a zone, which I think is called the ZoneModule. It’s available on the DevForum.
I can’t link it since the DevForum search isn’t all that great.
Yeah but as mentionned, there will be 200 zombies on the map. 200 pathfinding services running all at the same time will be hard for servers. Reason why I use moveto() and give the zombie the ability to destroy all the walls
my idea would be to make one script handle all 200 zombies
and I would use Move(Vector3) instead of MoveTo() that way you have way more controll over how they move, because MoveTo() still does some calculation, and it kinda suck, in my experience they just stop moving as soon as there’s any kind of steps in front of them,
you might think going through 200 Characters and moving them in specific direction might still cause some lag, but it’s not as bad as you might think, at least not as much as making 200 scripts that does allmost the exact thing(although I cannnot confirm, as I have never tried it, but then again, people to caluclations every single frame just to get the FPS so you know).
As stated in the original post: “What would be the most optimized Idea for zombies to be able to detect when they are in reach of a player to attack and when there is a wall to break that’s stopping them from reaching the player?”
The best way to do these types of NPCs would arguably be to make them completely custom and forgo Roblox humanoids altogether.
You could have them as small parts on the server that move to players using Pathfinding, and then render the body parts / accessories on top of the small parts on the client side.
This method takes a lot of work but would give you the chance to make something that puts significantly less strain on the server.
Also consider the server having to calculate physics collisions for all the body parts and accessories of 200 or 300 NPCs. Having them all as only one part could be very beneficial.