• Register
Post news Report RSS Implementing a smarter AI with native Unity tools

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 an easy fix to make a smarter AI.

Posted by on

goblin


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.

NOTE:
This video was filmed on location in Goblin Forest, and no Goblins were hurt during the filming of this video.

giphy lowres


The initial Goblin had just a few properties that controlled it’s behavior.

detectionrange

  1. The first property was Detection Range to the player was how far away the player could be until the Goblin ‘Spotted’ the player

lostsight

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

approachDistance

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

path1


He could go around to the right most part of the fence

path2


Or he could go around the left most part of the fence

path3


*Note*
Currently we don’t have plans for them to jump over obstacles, but that could change as we continue development.

aiDumb


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!

Watch the video here:
Please watch our new video about implementing a smarter AI using our Goblin character as our test dummy! Youtube.com #gamedev #indiegamedev #madewithunity #screenshotsaturday

Post a comment

Your comment will be anonymous unless you join the community. Or sign in with your social account: