Monday 9 December 2013

Patrolling AI

Now that I can create an enemy bot, the next level of programming is making it patrol an area.

AI bot moving around in a patrol

This is how the code looks like, now let's break it down:


When the level is loaded the bot will be spawned by the actor factory, this code was previously explained here. Then we are comparing objects, A will be the spawned enemy and B is an empty object that is linked to the bot's death, so is A==B the bot is dead, and A!=B it is alive and will execute the next instruction, which is trace the player then shoot it or not. In the lower section is the patrol route the bot will execute, between path nodes 0 and 1. It looks complicated but it is quite simple.

One thing I learned while programming this is that the "Target" in some blocks doesn't mean what it is going to shoot. It is the target of that action.

No comments :

Post a Comment