Wednesday 20 January 2016

Coding - AI Patrol - John Howard

Task

The first element of AI I needed to setup was the patrol system.

Stage One - Animator
The first thing that needed to be setup before even beginning the patrol code was that of an actual AI  itself. So I decided to take the ethan model from standard assets along with its animations. However I did not take the animator itself. I decided that if I am to setup a custom animator for the AI later I first must learn how to do so. To learn this I decided to follow the setup stages of the unity Stealth tutorial series, available here, this allowed me to create the animator myself but also make sure I was doing it in the correct manner. However I did avoid using Hash IDs as they have now become redundant in the newer unity version. Eventually I ended up with a working and functional blend tree for movement for the AI.

Stage Two - Patrolling

Naturally the next step was to begin the patrol code. I began with the idea that setting the NavmeshAgent(nav) destination would be the main way of developing this movement. By storing waypoints within a transform array I was able to set it so that upon reaching the nav.destination the waypoint index would go up by one, or if at end of array reset to start, and thus set the destination to the next waypoint. This system allows multiple waypoints from as little as two to as many as needed. Again the stealth tutorial was a lot of help for starting this. I also found out how to apply icons to empty gameobjects as gizmos. Which enables me to see objects without a renderer in the scene view.

Video


Thoughts

The patrol works as intended but I believe it can be redone in a much cleaner and better format. However the learning of arrays is a valuable tool and one that can be applied to multiple areas of this project. I shall revisit this patrol over the coming week or two and get it working in a better fashion. 

No comments:

Post a Comment