If-Else Statement — Make a Win Condition

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.

--

--

--

Unity Developer and Software Engineer who loves making games with GameDevHQ

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

Recommended from Medium

What’s HoF in JavaScript?

What is a higher order function example?

Making custom Pluto.jl interactive components! 🎈

Learn How to Create Your Own SDK Source for RingCentral Engage Digital

Using Gatsby-Plugin-Image With Contentful

The incredible Pipeline Operator

//platform.twitter.com/widgets.js from Twitter https://twitter.com/WadsworthArnold

A Coding Writer’s Guide: A Simple Explanation to ‘this’ in JavaScript

Insertion Sort (Javascript)

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
Al Heck

Al Heck

Unity Developer and Software Engineer who loves making games with GameDevHQ

More from Medium

Programs to build characters in

Why you should consider being part of our Sacrifice Event

Logo of Pulse Oxygen foundation

CRYPTOALIEN BEER CLUB

Terk - the most popular token in the crypto community, will bring the spring of Meme?