Welcome to our second video on our new project Ranger’s Quest. Today I will be sharing what was initially developed as a our AI, artificial intelligence; then what was wrong with it; and then finally how we implemented Unity’s Navigation Controller and Obstacle Avoidance system to smarten our Goblin enemies.
This video was filmed on location in Goblin Forest, and no Goblins were hurt during the filming of this video.
The initial Goblin had just a few properties that controlled it’s behavior.
- The first property was Detection Range to the player was how far away the player could be until the Goblin ‘Spotted’ the player
2. The second property was Lost Sight, which was how far away the player would have to get before the Goblin would ‘Lose’ the player
3. The last property was Approach Distance to the player, this was when the Goblin was approaching the Player how far away he would stop chasing and perform his attack.
The Detection Range looked in 360 degrees regardless if the player was insight or not. Upon entering that distance the goblin would turn and run straight to the player. As the player moved the Goblin would change his direction, but as you can see he would not try to dodge obstacles that may obstruct his path.
First he could easily fit within the gap between the fence posts
He could go around to the right most part of the fence
Or he could go around the left most part of the fence
Currently we don’t have plans for them to jump over obstacles, but that could change as we continue development.
So how do we implement a smarter AI? Using Unity’s NavMesh Agent that comes natively and freely with Unity! Check the description below for a link right to the documentation.
I had to slightly modify the pursuit script and bake the levels with specifying meshes as static, or immovable and not animated. [Display picture of level baked] The blue area is where the nav meshes can navigation, uncolored are parts they will avoid. While the easy part this was also the most time consuming part of the process. I had to modify a little bit of the parameters for the nav mesh but that’s also part of the fun. Experimenting with turn speed and chase speed parameters, but overall very happy with the result!