Keeping score
We now want to make it so that when we collect all of the orbs in the level, the goal will appear, and then you will win the game when you touch it:
- Go back into
MonoDevelop
, and select theGameController
class. Once there, add the following variables:public static GameController _instance; private int orbsCollected; private int orbsTotal;
Note
While it may make more sense English-wise to use
totalOrbs
andcollectedOrbs
, programming-wise, putting the common word first means that when you start typing orbs, it will show both options for you when working with code completion in your own projects. - As normal, we will need to set these variables as well in the
Start
function after theBuildLevel
function call, otherwise theOrb
objects will ...
Get Unity Game Development Blueprints now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.