Skip to Content
Learning C# 7 By Developing Games with Unity 2017 - Third Edition
book

Learning C# 7 By Developing Games with Unity 2017 - Third Edition

by Micael DaGraça, Grzegorz Lukosek
December 2017
Beginner content levelBeginner
290 pages
7h 17m
English
Packt Publishing
Content preview from Learning C# 7 By Developing Games with Unity 2017 - Third Edition

Gameplay loops

Well done so far. You have added basic functionality such as jumping, physics, and running to the PlayerController object. We are definitely going in the right direction here. The next important step is writing a neat GameManager class to help us control the game events, such as:

  • StartGame
  • GameOver
  • Restart

For basic games such as Jake on the mysterious planet, it is a good practice to have one instance of the GameManager running and controlling all main events in the game. The gameplay loop is simply a journey from the gameplay start to the gameplay phase and the game over phase. Time to write some code!

Let's create a new C# script and call it GameManager, and write the following code:

As you can see, nothing is very complicated. ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Mastering Unity 2017 Game Development with C# - Second Edition

Mastering Unity 2017 Game Development with C# - Second Edition

Alan Thorn

Publisher Resources

ISBN: 9781788478922Supplemental Content