Skip to content
This repository has been archived by the owner on Apr 2, 2022. It is now read-only.

Life System and Timer

ipar569 edited this page Oct 26, 2017 · 1 revision

Life System

The life system is a UI component that indicates the shared life between the players in the form of filled or not filled hearts. The hearts have been added to the top right corner of the game screen where many hearts systems are implemented for other game. There are 2 players for our game and the players share their life.

The system is integrated into the game using 2 scripts. One C# script is called 'HeartSystem' and another script is called 'Obstacles'. The 'HeartSystem' script is placed on the object called 'Team' with tag 'Team' which contains the objects for players to group players. 'Obstacle' script is placed on the objects that are meant to make players lose a life by colliding with the players. The script uses collider trigger to detect collision between the obstacles and player and calls the function inside the 'HeartSystem' which make players take damage. There are some other features that make players lose their life such as the reset button.

The code is based on the code developed by xOctoManx who streams tutorials on Youtube about Unity.

Timer

The timer is a UI element that is designed to indicate the score of the players. The timer is implemented using the script called 'timer'. The timer is placed on UI text object and changes the text as the time increment. The functions to record, pause, resume and reset the timer are implemented. When the game is paused or in a transition to another scene, the timer is paused to give no penalty to players.

The timer that is implemented is integrated with the leaderboard to show the high score of the teams who played the game.

Clone this wiki locally