Week 5 - Simple Game
This weeks focus was using last week's Unity project and expanding upon it by adding some game elements to it. The majority of this week's design was around "health". We had to design a player health system and make it so the enemies designed from last week hurt the player. We were also required to create a health pack to regenerate the players health. And to finish off, we had to create a "game over" screen for when the player ran out of health.
I started off by creating a spawner for the enemy to spawn from, as we were required to cause the enemies to "despawn" once they had collided with the player. I marked the spawner with a simple cube (Fig.1) to show where the enemies spawn from. After that, I got them to "despawn" when they collided with the player (Fig.2) by causing themselves to "deactivate", which essentially means to hide them.
I then added a simple health system to the player, with their health indicated on the top right of the screen, using Unity's canvas system (Fig.2).
The trickiest part was figuring out how to decrease the player's health when they collided with an enemy. I couldn't attach the function to the enemies as they would not be able to interact with the player's health script (at least not easily). I ended up adding a "trigger detection" script to the player and added some code that would detect the enemies.
I then created a health pack to heal the player (Fig.3). I created it using a capsule and 2 small cubes scaled together to form a plus sign. I even got the health pack to rotate around with some assistance from ChatGPT (Fig.4). Writing the code for the health pack was much simpler and Fig.5 shows the player collecting the health pack and restoring their health. I also added a cool down timer where the player must wait until they can pick the health pack up again to prevent the player from rapidly healing.
I then finished off by creating a "game over" screen when the player's health reaches 0. This was a relatively simple thing to make and I could've gone into a bit more detail such as making the edges of the screen more pronounced in depth compared to the centre (Fig.6).
If I had a bit more time, I would have added a explosion particle effect when the player died, as well as spice up the "game over" screen by adding buttons such as "restart". I would have also liked to have learned a way to make the health pack go slightly transparent to add some communication to the player that the health pack is currently on cool down.
I have attached the new Unity project if anyone wishes to experiment with it. Again, I have removed some assets as the file is too large.
Files
Get UTAS KIT207 Portfolio
UTAS KIT207 Portfolio
A collection of items that were created in the 2024 KIT207 Sem 1 course
Status | In development |
Author | LuddyFish |
Tags | portfolio |
More posts
- Week 6 - Visual PresentationApr 13, 2024
- Week 5 - Game IdeasMar 28, 2024
- Week 4 - Terrain and NavigationMar 23, 2024
- Week 3 - Character ModellingMar 16, 2024
- Week 1 & 2 - Tasmanian Tourist AttractionMar 06, 2024
Leave a comment
Log in with itch.io to leave a comment.