Enemy AI - The Plan

 I feel a bit bad picking on a game that is thirty years old, but the major problem of the original game is the enemy AI or more precisely the lack of it. 

In the remake, I am attempting to address this by building a more smarter and challenging enemy. To do this, I am using a state machine approach to handle the enemies.

I highly recommend this well-written article here for some background. I have also been using the author's code sample as my starting point. 

In the diagram above is my plan. 

At the zero level

Dead - this can be triggered from any other state, and as the title suggests means the enemy is dead. 

At the first level 

Guard - Enemy is at a static position in the game world, not moving 
Patrol - Enemy can move between two or more predetermined points 
Enroute - Enemy is moving to a predetermined point 
Roamer - Enemy is on a random path 
Reserve - Enemy is waiting in reserve. 

These first level states can be seen in this video here 


On the second level 

Inspect - enemy is alerted and heads in the player direction 
Attack -  enemy attacks the player 
BlitzKrieg - enemy reserves rush and attacks the player. 


I am on my fourth rewrite of the code to handle this, firstly last time I programmed anything substantial was a good ten years ago, so I am a little rusty and I am also fairly new to unity, which the game is being developed in. 

Those first level states are however working. my next step is to get the Dead state in there and working and then start on the second level states. 

Comments