Week 4, Part 2/2


This week I added some more features to the penguin chase, as well as adding some snow to the scene to make the penguins feel more at home. The penguins now spawn off screen to the left and right of camera, with a new penguin spawning every 3 seconds. This was achieved by creating an empty "Game Object" with a C# script attached which creates new penguin objects at that location and orientation. The player also has a health attribute as displayed in the top left corner. Another script detects when the player collides with a penguin, destroying the penguin in a puff of snow (using a particle system in Unity) and reducing the player's health by 1. There are also a number of health packs scattered throughout the scene which increase the player's health by 5 on collection. This is handled by the same script which deals with penguin collisions. The texture for the health packs was found on Adobe Stock images:

I chose a simple, square image so it will look good when applied to a cube in Unity, with all 6 sides of the cube looking identical. Finally, when the player's health reaches 0 the game will be over, with a message displayed on screen and the player being removed from the game. This last part caused me some issues as new penguins kept spawning in and trying to find the player object to chase. With the player object no longer active, the code caused an error trying to assign penguins a target which was non-existent. This was easy to fix with a quick "patch", but larger projects will require better planning to deal with such issues.

Here are some quick gifs to demonstrate the new features.


 

That's all for this week. Bye.

Get UTAS KIT207 Portfolio

Leave a comment

Log in with itch.io to leave a comment.