14 – Timer and Menus

For the past few days i’ve just been cleaning up and polishing the game, a part of that is a simple Menu and Pause system.

Changes/Tweaks

  • Timer system
  • UI: Main Menu, Pause and Win/Death menus
 

Timer System

This was my first foray into Unity UI so it took much longer than expected to do this – what I wanted was a system that allowed me to showcase the elapsed time in the current level which would be used for Time Challenge levels as stated in the GDD.

After following tutorials I had an initial version that essentially just showed the elapsed time, but today I revised that to be an actual timeLimit that counts down instead.

Picture

 
A thing of note is the timerOn boolean which I use to determine if the game is a Time Challenge level or not, as well as to determine if certain text shows or not which i’ll talk about further in the UI Menus section below.
 

UI: Main Menu, Pause and Win/Death Menus

This was also my first experience in doing menus in Unity or any other engine, I was surprised on how simple creating buttons was and how easy it was to just link them to existing code.
Picture

 
The buttons above simply called to functions within uiScript (which also contains the code for the timer seen above).

The biggest issue came from doing a Pause Menu, for that I had to look up how to stop time which is done via Time.timeScale.

Picture

 
Picture

 
Another issue I had was to determine how to make certain menus appear (for example only the Paused Menu appears and not the Death Menu).

The tutorial I followed used a tag based system where all objects for the Paused Menu were under the tag “UI_Pause” and it would just activate/deactivate all objects in an array of that tag (akin to me activating/deactivating powerup gameobjects seen in Entry 11).

This didn’t work for me for some reason so I ended up doing a workaround – the UI objects relating to Pause would be instead be stored as children to a ‘Pause’ gameobject which would be activated/deactivated instead.

 

Integrating Timer System into Menus

Picture

 
Building off the whole children UI elements idea I decided to do the same with the timer elements by using the timerOn boolean as a condition.
Picture

 
This is most prevalent in the winMenu: if the timerOn is true then the player’s elapsed time is shown in the winMenu otherwise it’s not.
Picture

 
 

Video

No video this time round, the next video will be of the final build for this module!

Leave a Reply

Your email address will not be published. Required fields are marked *

I accept that my given data and my IP address is sent to a server in the USA only for the purpose of spam prevention through the Akismet program.More information on Akismet and GDPR.