AI.. or a very simplified version of it

Hiya all!

So we decided that we needed some sort of critters running around in our game looking dumb, and they needed some sort of AI. This meant creating something that runs around randomly but always looks at Olivia. But we also wanted them to stay somewhat together, so some form of flocking is needed to create this.

At first I made two classes, one called Critters which all the critters would inherit from. Then I made the crittermanager, which would initialize all the critters, and also be responsible for updating all of them. Then I made a script that is added as a component for every critter object. The script sends gives the critter a random forward direction, and then sends out a raycast in that direction. If the raycast hits anything, another random direction is set. If the raycast does not hit anything, the critter runs in the forward direction. Now next step will be adding a search for other critters, if one critter runs too far away from the other critters, it should instead run towards the rest of the critters. You can find a pastebin for the current script for the critters here.

Picture of placeholder critter

critter.PNG

About Anton Olin

2015 Programming