Posted August 03, 2022 by corey_bigboi
This tutorial was about Navigation.
To start off with, I baked a NavMesh over my terrain / platforms. This represents the area that AI characters (agents) can travel across.
The NavMesh for my scene. The lines connecting between blue mesh represents 'jumps'.
I also made sure to include the obstacle cubes so that AI avoids it.
Space around the cubes means the agents won't bump into it.
With all this set up, I could create agents to use the mesh. I decided to make these agents into mini-me(s), as I had already made the animations. To control the agents, I used ray casts to direct them where I click in the game environment.
My minion army.
Minion dance party.
I also created a moving sphere to act as an obstacle, then added a "Nav Mesh Obstacle" component so that the AI treats it as such.
Moving sphere.
Epic dodging.
The final task was to create enemy AI that stalks the player. I repurposed the agent click navigation script to instantiate an enemy prefab at the mouse click location and also made a script for the enemy that moves it towards the player and always makes it face them.
Click for enemy.
Run away!
This was a fun tutorial that has a lot of potential to use in the game project later this semester.