Journal 145 — Unity Project Development, 2.5D Shooter

Chris Nielsen
4 min readJan 19, 2022

--

Objective: To fix the Main Menu and Game scenes and set up Audio

In the previous articles, I got the UI and mid-level boss and final boss working. I want to fix the Main Menu screen and also set up some sound effects and background music.

Main Menu

I’ll start with a new scene that contains a UI Canvas with a background image and some UI buttons for Start, Options, and Quit Game. The Options button will bring up a sub-menu to be able to modify the audio level and brightness level.

I’ll add a new C# script called MainMenu and attach it to the UI Canvas. We’ll need to add functions to set the Options menu active and inactive, quit the application, and load the game scene. Once these are set up, we can update the UI buttons with OnClick() events.

Also, be sure to update the Build Settings now that there’s a Menu scene and Game scene.

We can update the OnClick() events in the inspector by dragging the Canvas with the MainMenu script, and selecting the correct functions to load the game scene, Options menu, or quit application.

In the Options menu when set active, we need to update the Back button to turn the Options menu back to inactive.

Now, let’s see this in action.

Audio

Let’s add an empty game object called Audio Manager. I’ll add a background object and just play a looping track I found on freesound.org.

Then, I will pick out some weapon sounds for gunfire and missiles, vehicle sounds for the plane and helicopter movement, collectibles, and explosions.

Player Weapons

On the Player game object, I will add an Audio Source component. In the Player script, I’ll make an audio array to switch out the gunfire sounds to the weapon levels whenever the weapon is triggered in Update.

In the Inspector, I’ll add three sound clips I found in some Unity Asset packs.

Collectibles and Destroy

For the collectibles, I will add a script to the Audio Manager, and I will create a singleton and use functions to play the collectible pickup sounds and also play sound when a player or enemy is destroyed.

In the Enemy script, I will call the audio clip when destroyed.

In the power up script, I will play sounds when the OnTriggerEnter event is called.

Thank you for your time!

For the next article, I plan to work on some post processing effects and more polishing of my game.

--

--

Chris Nielsen

An Engineering Manager consultant who is seeking additional skills using Unity 3D for game and application development.