Developing AI with NavMesh
In this section, we are going to introduce a new enemy that will attempt to flee with frenzy-type behavior from our player's ship. This enemy's behavior will be implemented with the use of Unity's built-in NavMesh
functionality.
As you can imagine, this built-in feature from Unity can answer a lot of problems with regard to games with NPCs, similar to ones in the Metal Gear Solid game, where the player has to sneak around and not get detected by the enemy soldiers.
NavMesh
gives the enemy soldiers a path to walk around, and then if they see the player, their behavior changes from Patrolling
to Attack
.
So, with our game, we are going to implement NavMesh
but make it so that our enemies react differently to how they would in Metal Gear Solid. We will add multiple flee enemies in clusters to our third-level scene. This chaotic, distracting behavior will make the final level more challenging for our players.
The following screenshot...