Tales I Tell by Devmee Silva

let me first refresh your mind by stating about the "AURA" which is acting like a mediator between ourselves and the universe. 2. The law of Vibration The well-known numerologist Novalee Wilder once…

Smartphone

独家优惠奖金 100% 高达 1 BTC + 180 免费旋转




Loading Scenes in Unity

Scenes in Unity are important, as they help the user interpret when they are going to a new unique level or even a new screen like a start menu when the game first loads up. We’ve already created a Game Over Screen by using UI elements in our Game Scene. Let’s create functionality to restart the game from a game-over state by using Unity’s Scene Management.

Loading Scenes In Unity

Let’s make sure the Game Scene that we already have is added to our Build Settings. If we don’t check for this, the scene will not be recognized by the Unity Editor when you try to access it in our script.

File > Build Settings

Next, we are going to add a new script and name it GameManager. We do this because it makes sense to have our scene management in 1 script instead of us having scene management across multiple scripts.

Once that’s done, we are going to add our Unity Scene Management library to the new GameManager script.

Now we will create a bool variable to handle the state of Game Over.

Now, in our Update() method, set the user input to the key that you want to use to restart the game. In this instance, we are using the “R” key. When then use this as a condition in our if statement and then use the SceneManager to load the screen that we want that set as an index value from our build settings. In our case, since I already created a main menu and set it to 0, we have to load scene 1 since that is the game scene that we would like to restart.

Now let’s head over to our UIManager script and use some Script Communication to allow our script to trigger a game-over state when the player has been destroyed or ran out of lives.

And now we have a fully functional restart game sequence.

Let’s add some more effects to our enemies when our laser collides with them.

Add a comment

Related posts:

A Quick Update for Anyone Wondering

Summer is whizzing by here in New England. It never ceases to amaze me how much life and activity we fit into these short months in Maine. Every day is filled with beaches, hiking, trying that new…

Competitors Watch Example

Season II November 2018. “Competitors Watch Example” is published by Kilian Bazin.

Enkronos Apps are online!!

We are excited to announce you that, in advance of 12 days on our planning, yesterday we published our Enkronos Apps, with free access for everybody logging in from https://apps.enkronos.com…