Creating Elevator in Unity — Part 2: Require Coins.

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

Rusben Guzman
Feb 1, 2022

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.

--

--

Rusben Guzman
Rusben Guzman

Written by 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.

No responses yet