How to make advanced zombie AI

This tutorial goes over the basics of planning and setting up a zombie AI from scratch.
This includes:
-idle state
-run/walk towards player state
-pathfinding around objects state
-hitting player state

Most people starting out in BGE want to create some sort of zombie shooter game, so I figured I might as well make a tutorial on it :wink:

Enjoy :D!

1 Like

I love zombies. :slight_smile: Good job Tim. That’s exactly the way I do it, with the exception of the Navmesh. Zombies can’t rationalize obstacles. Which is why they’re always stuck on things. LOL Kidding. I bone parent a cube (hitbox) to the zombies head bone, static, ghost, actor, invisible. then interconnect that to the zombies death state. because the only way to kill a zombie is to kill it’s brain. :slight_smile:

Thanks! for hit boxes is probably a good idea to use a sensor for detection of bullets/hit points.
Since zombies are fictional though, the virus could have infected and embedded itself in the nervous system, making the brain redundant as this would otherwise be a weakpoint. In this case the only way to kill them would be to dismember the zombie or destroy the spine, but this is up to you and how you want to interpret a zombie virus ;).

I find the navmesh is a good starting point to keep the gameplay interesting, otherwise having 7 zombies stuck behind a wooden board isn’t very fun.

I was just joking about the zombies, of course you 're right, anyone can do anything they want. :slight_smile:

probably a good idea to use a sensor for detection of bullets/hit points.

Yeah in most cases, but, not for me. For example. My FPS uses a bow and arrow in addition to other weapons. The arrow (arrow_add) sticks in an object with the property “soft” and sets parent the object. So the zombie can walk with an arrow in its head. I can’t get it to work as a sensor.
I use an old bullethole script written by Social, (I think) and updated by HG1 for 2.6* modified slightly by me, to add the arrow and align it at the vector it was shot from. then a script on the “arrow_add” to parent it to the object.

I find the navmesh is a good starting point to keep the gameplay interesting, otherwise having 7 zombies stuck behind a wooden board isn’t very fun.

Yeah the Navmesh is a great addition. You’ll laugh, but, I still use a track-to-closest object script and spawn nodes. Old habits die hard I guess. I’ll be doing more with a navmesh in the future.

Looking forward to your next video. :slight_smile: And great job with Undertow, love it.

Yes zombies are subjective to the creator :wink:

For a bow and arrow I think this is a better idea! Usually for a first person shooter (with a gun) you will use a sensor on the zombie and either make the zombie mesh static or add a static hitbox to trigger the ray (smaller than the sensor).
Then when the ray hits the hitbox, it will spawn a static ‘hitpoint’ which will trigger the sensor.
This way you don’t need any dynamic/rigid body physics, however again it usually only works for things like guns and in your case since you are using a dynamic projectile it’s probably easiest just to use a static sensor.

track-to-closest might be a bit difficult in regards to navigating around obstacles and walls, but usually if you only have 1 player it’s a bit of a waste to find the nearest object, since there is always only one object to find.

Thanks :smiley: its great to see so many people making great games!

if you want smarter zombies you need to feed them brains :smiley:

I’m not sure if this works or not, i’ll have to test it :wink:

Mind blowing stuff. Thanks for sharing. :rofl::joy::grin::laughing: