Zombie AI Mechanics



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.

i suggest you to take a loot at pathFinding

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.

DevForum search moment

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.

1 Like

Do you mean ZonePlus?

1 Like

Looking into Roblox Pathfinding is really good! There’s some really good Forums that get really in-depth

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).

don’t use region3 it’s outdated, use GetPartsInPart(), GetPartBoundsInBox or GetPartBoundsInRadius

1 Like

You could cast a ray from the zombie’s head to the nearest player and see if any destroyable blocks intersect the ray.

1 Like

Problem is that if the player moves, the humanoid will go to its old position and therefor not follow the human properly.

1 Like

This is an amazing idea, ill try it out!
Thank you

the server script should go through all 200 zombies and set their move direction with while true do

1 Like

I smell the roblox servers burning just from hearing that. Ive tried my method and it works super well with 300 zombies and close to no lag at all.

1 Like

then what was this post for? it seems pointless if you didn’t have any problems in the first place

1 Like

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?”

I never talked about zombie movements

1 Like

obviously the best solution is to actually not do anything and go to the player’s character.

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.

1 Like

Amazing idea, ill keep it in mind for future projects since I’m not at that level of coding yet.
But from what I understood, the server would only load parts that would slowly pathfind towards the player, and all animations & character physics would be handled locally?