- Home /
Zombies AI
So i'm making a zombie apocalypse game, about 3 months now, a lot of things are done, everything is perfect, so now i want to make a script for zombies to attack me when they see me... I want to ask you guys, what do you think is the best way to make AI for them ? What should i use, any ideas ? I was thinking about using raycasts going from zombies eyes to ground, or something like that, so i just want to know what do you think is the best way to make it.
If you are making a 3D game, use a frustum* camera combined with Vector3.Distances to check if they see you or not. Then if they detect you, simply use a Quaternion with lerping to rotate towards player, and move forward. Repeat until player reached or he runs away, where they then continue on a randomized path
Answer by Calum-McManus · Mar 06, 2014 at 02:35 PM
This should really be in the forums but I may as well answer it while it's here! There are many different systems you can do this but the way I tend to do it is to have different modes the Enemy can be in, so something like this:
Idle (Idle animation on the spot)
Wondering/Patrolling(Following a way point system)
Alerted(Something happens e.g. hears foot steps, and changed course to check out the noise)
Attacking(Walking towards you, use Vector3.Distance so it stops near you and begins its attack and repeat)
For zombies it can vary as different zombies may have different ability's (Thinking like Left For Dead) or just normal generic dumb/aggressive zombies that will attack a tree if it makes a noise xD this system makes it easier to change later on as well if you make a good waypoint script as it can all run from that one script and just changing the state of the AI and the next way point it must go to! GoodLuck!
Thanks for your answer, and yeah i had to put it on forums not here, my mistake.
Answer by ReaperMK · Mar 06, 2014 at 03:24 PM
Wandering scripts are very useful for this type of situation as stated by Mcmanus... I also recommend checking out bird flocking behavior to make your zombies seem more in tune with each other. In most zombie films you see groups of zombies flocking together tearing through towns and eating brains - use media and film to define a style of zombie you want your game to portray and define the movement using these references. Flocking behaviors are great as well as wandering, vision systems, and alerted systems. Typically you can define a radius in which the zombie will agro but it can also help to have alternative alert systems so the player does not get too accustomed to a particular radius and kite the zombies all the time. Having varying zombie movement styles, alert types, and movement patterns can increase replay value as well as difficulty and realism.
Raycasting is not a bad start - I used this for a stealth game at one point and it is a very good way at simulating vision area if coded properly.
Hope this helped! -Mitch
Hmm. Really interesting idea, this one's the best idea in my opinion, thank you.