PUZZLE
816
2
2

Brute Force Breakout

by

You, a lead high-ranking officer from the Security, Safety, and Protection Corp., have been selected to maintain the security system at the detention center located on the outskirt of Capital City.

You are tasked to create the code that will secure the whole center. But beware, If you fail, Capital City will be doomed!

  • Used a singleton script to prevent background music from being interrupted during transitions to scenes with the same music. Thanks to BMeta and BackNowhere for pointing it out and giving me the solution!

Roasts

BMeta 1 year ago

UI Graphics Physics
One issue that I noticed is that many of the menu transitions restart whichever song is playing
Reply

DjinnAlexio 1 year ago

Thank you! I will see what I can do.
Reply

BackNowhere 1 year ago

Hey DjinnAlexio,

I had the same problem with a product a few years ago. I had a MusicController object in each scene. Not really the way forward.

The solution was to use a Singleton-esque style pattern. If you put the line: "DontDestroyOnLoad(gameObject);" into Start(), then your MusicController object will hang around betwenn scenes :)

Getting a static reference to the object itself and removing any other instances is usually a good idea too.

class MusicManager: Monobehaviour
public static MusicManager musicSingleton; // static reference to our music manager

void Awake()
{
if(musicSingleton == null)
{
musicSingleton = this;
}
else
{
Destroy(gameObject);//if a music manager already exists then delete self.
}
}
Reply

DjinnAlexio 1 year ago

Thank you BackNowhere,
I didn't know the singleton could be implemented like that. I'll try both the one I know and the one you explained to see what works best in this case.
Reply
Roast Em
SHARE THIS ROAST

Related Games