Creating Elevator in Unity — Part 2: Require Coins.

Require a specific amount of coins before being able to call the elevator.

Objective: add a new condition to check if the player has 8 or more coins to call the elevator.

In the elevator panel script I declared an int variable that represents the quantity of coins the player needs to call the elevator. Then in the OnTriggerEnter function in the if statement where I check if the player pressed the “E” key I added a new condition to check if the current quantity of coins the player has is greater than the required coins and if it is true the player can call the elevator.

And that’s it!!! Now the player needs coins to call the elevator.

--

--

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
Rusben Guzman

A Software Engineer passionate about game dev and interactive products with Unity. I consider video games to be the artistic expression of programming.