Self Study 4 - Unity


Building on Tutorial 3,  the goal for this self study was to add health to the player and for the AI to damage them when in contact. Additional things were to spawn the agents from a spawner and then chasing the player rather than clicking them in, health packs the player can pick up and displaying the players health and when it is game over. The scripts for health, spawner and trigger detection were provided so it was mostly adding them to the necessary components to get things working.

First thing I did was create a health pack model in Blender so there was something unique in the game that was easily identifiable as health.

I also made a hovering animation for it in Blender and then looped it in Unity as in most games, a pickup can be identified not only by its visuals but also by it hovering and/or spinning.


Next I added the health script to the player barrel which required adding UI so the player knew what their health was and when it was game over. I added the UI onto the camera so it was always in the same spots and also changed the colour of the text depending on how much health they have. Green for greater than 5, yellow for 5 to 2, and red for 1 or game over. I then created spawners on the map that would spawn the AI every few seconds and automatically chase the player to try damage them. The damage system used Unity's Event system which allows easy communication between objects such as when the AI touches the player, telling the player that the AI is dealing 1 damage to them and then destroying themselves. For the player, when their health reached 0, the game will end with the player model being destroyed and Game Over displayed where the health was. The trigger detection script provided a generic template that allowed me to use it on any things while giving me flexibility of what happened when that object contacted the player. This would be more tedious if I had to code this as I would need to write a different script for the health pickup and AI object.


The health pick ups worked the same way as the AI but instead of dealing damage, they gave 5 health to the player. Health was a one time pick up so like the AI, destroyed themselves once they contacted the player.


While the game is simple overall, it still feels like the AI is smart with their ability to predict your movement and knowing the shortest path to get there. Even if you try to bunch them up in a group, some will split off and stop following your previous path as they know to get in front of you which makes it fun to try outsmart them.

Leave a comment

Log in with itch.io to leave a comment.