Adding Background Music in Unity

Now that we’ve added post processing to make our game look like a AAA title we need to round it out with sound! If we really want to immerse our players into our game sound plays a huge part in it! From the subtle background sounds of birds and foot steps in a jungle based first-person shooter to the sound of that particularly nasty lock puzzle hitting the ground after you’ve solved it in your favorite escape room VR game, sound can be just as important for a players immersion as the visuals they are presented. …

Excluding Objects from Post Processing

In our previous article we took a look at adding post processing to our scene to add effects like Bloom and Color Correction. I have found, while working on a project that sometimes you have objects that you don’t want to apply post processing to. Let’s take a look at how I have excluded some objects from post processing.

While play-testing, I found that the bloom effect was causing my shield visualizer to burn hotter than the sun! This was not my intended effect and I quite liked the effect of the shield visualizer without the bloom effect.

Shields before and after post processing

This led…

How to use Post Processing in Unity

Post processing in Unity is the processes used to add effects and adjustments to the rendered output of your game before the final image is displayed. I like to think of this process as being like adding filters to an image in photoshop to get different effects like adding grain to the image or adjusting the colors. Today we’ll take a brief look at what it takes to set up and apply post processing to our game.

First things first! We need to install the post processing package from the Unity package Manager. …

Damage VFX using Animated Sprites in Unity

Photo by Taylor Peake on Unsplash

Yesterday we took a look at creating explosion animations when our enemies were destroyed. Today, we’re going to give our player a visual indication of the damage that their ship has taken. This process is very similar in how we create and display the animation that represents our ships damage level. Most of the difference is in the code we use to display it. Let’s jump in!

First we create our new damage animation in much the same way as we did our explosions. We drag the first frame of our animation sprites into our hierarchy, rename it, open the…

Creating Enemy Explosions

Photo by Luke Jernejcic on Unsplash

Today, we make our enemies go boom! Let’s look at adding explosion animations to our enemy objects. To get started we’ll open our Enemy prefab and, with our enemy object selected, open our animation window. Clicking on the create button will let us create our animation and a controller for it. Then we’ll drag the sprites for our animation into the dope sheet.

Loading Scenes in Unity

Now that we have a game over screen let’s give our players a main menu screen when they first load the game! To start let’s create a new scene in our scenes folder in the project window and name it Main_Menu.

Creating a Retro Game Over Behavior

So you’ve been defeated by the alien ships? That means Game Over! What better way to show the player that they lost than a retro style “Game Over” screen? Let’s create it!

For the Game Over screen we actually don’t even need to create a new screen, though we might in future versions or other games. In our case we simply need to create 2 text objects and add them to our canvas. One for our Game Over text, and a second for the instructions to restart the level.

Ease of Building UI Elements in Unity’

Photo by Harpal Singh on Unsplash

Feedback on a games state is critical for the user's ability to make choices about how to interact with the game. Unity makes creating user interfaces easy and intuitive.

We start by adding a canvas to our hierarchy. They can do this by right clicking on the hierarchy window and choosing UI > Canvas. This will create a canvas object in our scene, and we will add our UI elements to this canvas that sits on top of our game by default. …

Enums, switch statements, and avoiding magic numbers

Photo by Julius Drost on Unsplash

Yesterday we took a look at extending our power up system to include a new power up, the speed power up. Today we are adding another power up, the shield power up. Since a lot of the process of adding another power up is the same, I’m going to discuss something related instead of going over the step by step of adding our third power up. That would be avoiding magic numbers.

Creating Modular Powerup Systems

Photo by Ryan Quintal on Unsplash

Yesterday we discussed some tuning of our game and how long our powerups should last. Today we’re adding a new powerup! So far we have our triple shot powerup. Now we want to add a speed boost powerup. It’s likely that we will want to make more powerups in the future as well. We don’t want to reinvent (or worse copy and paste) the powerup collectible behavior every time we create a new power up, so let’s modularize our powerup script!

To do this we will want to add an identifier of some type so that we know which type…

Christopher West

Unity Game Developer, Software Engineer, Gamer, Musician, and Father. Christopher is a creative that enjoys a challenge and loves coding.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store