Nerd For Tech
Published in

Nerd For Tech

Creating an elevator in Unity, part 2: Paying the cost

Yesterday, we got the panel initially working, One of the requirements to use this elevator is having 8 coins, so let’s get right into it and create a variable for it!

As stated before, we hardly ever want to hard-code numbers for items, you want to keep things flexible so here we’ll keep it available for any dev that may want to change the amount of required coins to tweak game balance for example.

While the player does have a _coins variable, it’s private and we don’t want to change it to public. Fortunately, we can just create a public method that will return the amount of coins that we’ll be able to call. Open up the player script and we’ll add it.

Fantastic! We can now use this newly available information method to check in our elevator panel!

Great! Let’s check if it works by missing 1 coin.

So far so good! It’s not turning green while I spam the e key, let’s pick up the last coin and try it.

Awesome! The light’s turning green because we have 8 coins!

Tomorrow we’ll bring the elevator down!

NFT is an Educational Media House. Our mission is to bring the invaluable knowledge and experiences of experts from all over the world to the novice. To know more about us, visit

Recommended from Medium

Flutter MethodChannel, Dart Generic and Type-Casting

Symfony Request & Response flow

Haskell Applicative functors

Kubernetes(K8s): Everything you Need to Know about K8s

Dev Protocol Community Shop is now open!

How we leveraged and custom CA for Otomi

Create Your Dataset by Web Scraping Using Python BeautifulSoup

[Work][Python]Spec power automation-3

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
Esteban Ibarra

Esteban Ibarra

cartoonist, game artist, and wanabe gamedev.

More from Medium

Using Signal Emitters in Timeline to Access C# Scripts

Creating a UI Shield Strength indicator

Enabling Unity Ads

Unity Feature 101: Resources Class