Wibbly Wobbly, Timey Wimey

Yes, in the blog-post for this week we will learn all about the manipulation of time, and the evi- I mean great and different ways one can use this knowledge in your game.

Anyway, in all seriousness. Yes, this week has been all about time manipulation. The reason? We’re less than a week away from the Beta hand-in and our game still doesn’t have a working menu, pause menu or tutorial (oops).

Thus I, a simple programmer, took it upon myself to make sprites and other graphical assets needed to make the missing features.


So, what did I do and how did I do it?

Well let’s start of by explaining the plan:

The game we’re currently making is all about instant fun and instant play. We don’t want no pesky menus keeping our players from getting to the juicy goodness that is our game! So, It was decided to just skip a main menu all together!

When the player first boots up the game they will be introduced by the standard unity splash screen (and possibly a custom splash screen in the future, ooo fancy).

After which they will instantly be dropped into a playable tutorial. The tutorial has a very simple setup:

Player is in -> player sees button prompt on the “floor” of the game -> player follows button prompt -> button prompt updates to next button prompt, after giving the player a few seconds to familiarize themselves with the controls they just tried.

This is done three (3) times: starting with basic controls (showing the W,A,S and D keys), changing it into a left mouse button click (used for shooting), and finally ending it with the right mouse button click (used to teleport).

After the player has followed these very simple steps, the game will switch over to “play-mode”. This will start the spawning of enemies and thus starting the game itself. If the player was to die (or rather: once they finally do die) the game will restart from “play-mode”. Meaning they don’t have to redo the tutorial sequence again.

But “wait! where’s the main menu? How do players quit the game!?” you might ask.

Well it’s very simple, instead of having an entire main menu screen, it was decided to skip this step all together and instead just have a pause menu.

This pause menu contains the following items:

  1. A “Quit” button that exits the program.
  2. A “Scoreboard” button that access the scoreboard, displaying the top scores (yet to be implemented).
  3. Sound settings (As it’s not that complex of a game sound settings where the only thing we decided on adding for the time being).
  4. Credits (Showing that we made the game, who we are in the group and what we did)
  5. The game logo
  6. The highest score currently saved on the machine (giving instant access to the player to see who’s the top-dog and what they need to beat them. Without having them go into the scoreboard. Again, not yet implemented).
The credits section is a subject of change since we’ve recently outsourced the work to make a logo and splash screen to a new 5th member of the project.

The game will “freeze” when players decide to access this menu, no matter where they are in the game. But how do you freeze the game?


For anyone who doesn’t know how time works in unity let me explain:

Time is a variable that is constantly increasing when an application is being used. This incremental increase is based upon a timescale (see where I’m going with this?). If an individual is interested in halting, slowing or even speeding this process up. Then they can do so by accessing this timescale using the line “Time.timescale” in a unity script, the base value of the time scale is 1.


In our case, whenever the player decides to click the pause button (set to the escape key) a function is called, the pseudo code is as follows:

First of the time scale is set to 0, this freezes the game (Note: this freezes anything that uses the “FixedUpdate”, as well as anything that uses “Time”. The “Update” function still works normally).

The function then pauses the music source (this is more of a quick fix to stop the rhythm of the game to get out of sync with all the moving parts).

The pause menu canvas is then enabled and the cursor is set to be visible.


NOTE: The player already uses the mouse inputs for shooting and teleportation. Adding an “if” statement either inside the input check or before it that checks if the timescale is NOT set to 0, will stop the player object from shooting or teleport if the pause menu is active.


If the player, at any moment was to click the pause button (Escape) again. Then just reverse all the changes.

This was a very simple way of implementing a pause function into our game, and has thus far worked without any major problems.


Post Programming thoughts:

This week didn’t have a lot of work to it, most parts of the game are already implemented, the only things really missing are player scores and some sort of menu. And thus, there wasn’t a lot that could go wrong.

Nevertheless, there was one very annoying thing that did:

When working with multiple people on a project make sure you keep a good eye on which scene you’re working in.

I have mentioned once before about how you can do several hours of work on a project only to realize that the work can’t be saved into the cloud.

Well, sometimes, things that are loaded from the cloud can mess things up too!

This week’s screw-up involved an incident where I had just finished a large portion of the pause menu when a new version of the game was pushed to the cloud. Wanting to make sure that the things I was working on worked with this new version, I decided to download it.

When the process finished, it warned me that things would be changed in parts of the project. Thinking nothing of it (as it is a common thing to get this warning) I accepted the risk.

It was at that point I realized, I messed up. I had worked in a scene that wasn’t “mine” to work and test things in. So, when this new version was loaded it removed all my work from that scene, overwriting it with the downloaded version.

And I had to redo all that work again. Making sure I did it in my own scene.

So, a word of warning: when working in a scene, make sure you’re doing it in a scene which you know won’t be manipulated from the outside. Or you might find yourself having to redo all that work somewhere else.


Post post thought:

I made the title and beginning of this post to look like I would mainly talk about time manipulation in unity. But ended up mainly talking about menus and tutorials instead. If you happen to have been more interested in more of the time stuff, then… sorry about that?