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:

Image for post
Image for post

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:

Image for post
Image for post
Way points list highlighted above is what is holding the guard positions.

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.

Image for post
Image for post


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

See you then.

Written by

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