If-Else Statement — Make a Win Condition

Al Heck
Apr 22, 2021

We have a cube. Each time we press the space, we want to add 10 points to a total. When it hits 50, you win and it turns the cube green.

To do this, let’s start by setting up the variables necessary for the score condition, our object, and our renderer.

Next, we want to get the component of renderer inside of our object.

Finally, let’s do a simple update method that adds 10 points per space press. If our current score is greater than our grandTotal, let’s change the color of our cube and show our win condition.

--

--

Al Heck

Unity Developer and Software Engineer who loves making games with GameDevHQ