Thursday, 24 March 2016

Coding - Cover Test - John Howard

Task

To try create a basic cover AI

Overview

I wanted to try and push towards creating a cover AI script. One that would allow me to, with altering the golem scripts, set up the skulker. I was very confused on how to approach this to begin this and so had to look at many different videos to get some ideas.

I began to piece together the notion of using nodes to act as cover points and thus I began coding. Firstly I set up a main cover holder which would be the main body of cover. For example a wall or rock. I created a tag for these called "Cover". I then created a cover selector script on the AI test cube. What this script does is firstly create an array and store all objects tagged cover. I would want to change  this to an area around the AI so the array would constantly be getting filled and emptied. However for now this will do. Using an InvokeRepeating function I force the AI to chose the closest piece of cover at any one point.
Under each cover game object are numerous child Nodes each node has a cover checker script on it. Each has a goodcover bool on it. This bool is turned off when a ray from the cover to the player is not obstructed and turned on when the node cannot see the player. The selector script then fills up a node array with the selected covers child objects, the nodes, and selects the closest node that cannot see the player and moves there. See video below.

Thoughts

This is a very buggy script that needs multiple iterations to work better with many different things needed to be taken into consideration. However I feel I must leave this script and function for now and fully focus on doing a final set of iterations for the golem and make that one as good as possible. However I believe I could come back to this and make a cover script that works much better.

No comments:

Post a Comment