60 days to become a game developer. Days 38 & 39.

Hello there! Here is a recap of Days 38 & 39 of my 60 day challenge to become a Unity Game Developer :)

I’ve been working on the enemy behavior!

Take a look:

Here you can see the enemy moving back and forth. He also pauses for 2 seconds using a Coroutine and then continues on his set path.

Aside from creating a Coroutine, here are some of the other things that were needed in order to create the behavior shown above:

First a Nav Mesh agent needed to be added to all of the guard components. Just like the player, the Nav Mesh agent is what is being used to move the enemy around the board. A new script also needed to be added to handle their logic. I learned a lot working on this enemy behavior script :) This was my first time using list in Unity and I love how versatile it seems to be. In this case for the enemy character, a list was used to create an index for the different positions that the enemy would rotate between. Using a list provides is a bit more flexible than an array, for example you do not need to specify the list size up front.

Here’s what a list look like in the Inspector:

To set the positions for the guard to move between, its prefab was duplicated once for each position, moved to its designated spot in the game scene, renamed and grouped into a new game object. By doing it this way, you can make reference to the positions using drag and drop into the inspector as shown above.

Also saw how to make code much more dynamic by using an int variable to reference the index rather than hard coding everything in.


  • My guard has a bug where he sometimes goes off track or doesn’t reach his destination. Will try to comb through that tomorrow.

Tomorrow I will be finishing up the enemy behavior and will start working on some other neat features of the game!

See you then.