Creating Elevator in Unity — Part 2: Require Coins.

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.

--

--

--

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

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

Recommended from Medium

Adding Gravity in Unity

Programmer jokes #8

SlinkyFinance NFT FARM

Simple CRUD application in laravel 5.8 Part-1

Flashing ROM using SP Flash Tool

Simple Things That Makes Your Code Look Better

SQL From Zero to Hero in 30 Days — Day 3 Filtering

Installing a KubeFlow on your Local Machine

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

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.

More from Medium

Using Signal Emitters in Timeline to Alter Playback — Unity

HitBox Attack System in Unity

Creating a Pressure Pad in Unity

Modular Health System in Unity!