Platformer: Resetting the Level

Introduction

In this quick article, I will cover how to reset or restart a level. In this example, when the player is out of lives the level will automatically reset. This technique to be used with input, like if the R key is pressed then restart the level.

The Code

We will need access to the Scene Management library, so we can load different or the same scene.

In our Lose Life method, we want to check if the player’s lives is less than 0 then we will access the SceneManager and call LoadScene method. We will have to pass in the scene index we want to load. Currently, this is the only scene so the index is 0.

This is a small feature and is something mostly never thought about when playing games, but as a game developer is expected to put incorporated in games in some fashion.

Keep Coding & Cheers!

--

--

--

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Handy Tips & Tricks for Zigbee2MQTT

Hello world

Very well written explanation on concept drift!

TOP 10 PROGRAMMING LANGUAGES USED IN AI CHATBOT BUILDING

TOP 10 PROGRAMMING LANGUAGES USED IN AI CHATBOT BUILDING

How to use two types across assemblies with the same fully-qualified type names in C#

6 Essential Tips on How to Become a Full Stack Developer

Introducing CodeCast Series ✨

Use Google as login in your web app with OAuth2

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
Ryan McCoach

Ryan McCoach

More from Medium

Structuring Your Unity Code For Production: Important Best Practices

Mastering Unity Scripting | Summary — Chapter 2: Debugging

Asset Bundles for Unity

Mastering Tessellation Shaders and Their Many Uses in Unity