In this video, Jesse Freeman teaches you how to restart the game after the player has died. Restarting the game in a simple way allows your player to quickly return to the action and complete the game's compulsion loop. Learning how build a game loop in Unity 5 is an import skills for building a 2D game.
- [Voiceover] So now when the player dies,…we're able to slow down time…to give us the effect like the game is stopping.…Now let's look into how to restore time…and make the game start again.…By selecting our game manager…let's open the game manager script.…At the top of the class,…let's go in and create another private property…called gameStarted.…This is gonna be a Boolean…and we're gonna use this as a flag…to know when the game has actually started…or when the game is over.…
Now, when we reset the game,…let's set the gameStarted flag to true.…Now, where we call OnPlayerKilled…we're gonna set the gameStarted flag to equal false.…Next, in the update loop,…we're gonna wanna test.…If the game time equals zero,…we know that the game is over.…We can also use the gameStarted flag…to validate this.…Once we detect that this is over,…we're gonna listen for the anyKey,…and whenever that happens,…we're gonna turn time back to its default value of one…and we're gonna reset the game.…
So here we're gonna test the gameStarted…does not equal true…
Start watching to learn how to convert artwork into sprites, create repeating background textures with Unity's TexturePacker, and build reusable game objects such as players, obstacles, and enemies. Jesse also covers the basics of object pooling, working with custom UI components, and multiplatform publishing.
- Importing artwork
- Editing sprites
- Creating repeating background textures
- Building reusable obstacles
- Recycling game objects
- Building an object pool
- Creating the player
- Starting and ending the game
- Displaying and saving the score
- Adding menus and text
- Publishing a Unity game in different formats
Skill Level Beginner
1. Working with Sprites
2. Creating Repeating Textures
3. Creating Obstacles
4. Object Pooling
5. Creating the Player
6. Setting Up the Game
7. Polishing the Game
8. Creating More Obstacles
Publish to different formats5m 42s
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.