AI Movement
With the traversable path now established for the AI, it’s time to assign them some basic movement function.
Before assigning the enemies their specific path, I set up an end goal for the AI to move towards. This is simply an invisible square that will be able to detect collisions and hold a transform for the AI to navigate towards.
Next, I made a total of 9 “waypoints” that were all behind pillars, out of sight of the player. These are safe zones the AI will select during their transit to use as cover from the player’s attacks.
With these things established, I set up the first version of the AI: Move to the end goal.
In code, its as simple as instructing the NavMeshAgent to navigate to a new transform.position.
Next time I will cover the AI states; Run, Hide, and Die. The AI will select which waypoint it thinks is can safely reach, then hide there for a random amount of time before continuing forward. The die state will handle on enemy death logic.