The Path of the Game Dev — Day 23

Saving progress…

— —

Oh man is this all getting more and more exciting!

The next section focused on building the enemy AI for the guards of the stealth game level. Similar to the player, the guards also use the NavMesh to move around the environment. The key difference here, however, is that the player moves with input from the mouse. The guards are meant to automatically move around the level on their own. So how do we do this?

With UnityEngine.AI and SetDestination, you can make waypoints for the guards to move between. However, you have to set parameters to account for any weirdness that comes along with incrementing and decrementing values outside of the list size. This took a lot of thinking through specific conditions, if statements, and pausing and replaying the game to make sure things weren’t breaking.

Working with the animator these past two days has been quite the experience. Everything was going smoothly for the player character and then suddenly I get to the guards and… well. Let’s take a look.

Dancing guards in a stealth game

The guards have no problem cycling through their walking animation and moving to each waypoint but once they start their idle animation they rotate back and forth on the Y-axis. At first I thought it had something to do with the coroutine since that’s the method that is called when they start their idle animation, but no, everything in there was fine. I tried looking back through Update to see if there was anything messing with it there, but I also couldn’t find the source of the rotation. Maybe more research is necessary.

Biggest takeaways from the day: AI is fun to work with! Animation is not (for now).

— —

Progress saved!



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store