Create a Coin Distraction Feature in Unity (Part 2)

Objective: create a code to limit the quantity of coins a player can toss.

In the player script let’s create an int variable to represent the quantity of coins the player has available.

In the update method we have to check before instantiate the coin if the player have more than 0 coins, if it’s true we can instantiate the coin and decrease the coins variable.

And that’s it!!! When the player has 0 coins you can make a right click but no coin is going to be instantiated.

--

--

--

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 multiple parameters to a DAX query as a filter in Power BI Report Builder

I can’t test that! (Part II)

Installing another virtual host probe example — Shopware community edition.

Why I want this.

Today, if you are interview prepping, you’re going to have to spend some late evenings practicing

Learn Python pt.3 — If.. Elif .. Else

Indeed’s FOSS Contributor Fund: 2021 Updates

FOSS Contributor Fund logo

Tutorial ESP32 Door Lock 3in1 Fingerprint Keypad 4x3 and RFID PN532

Tutorial ESP32 Door Lock 3in1 Fingerprint Keypad 4x3 and RFID PN532

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

How to Create A Loading Scene in Unity

Cross-platform Input Controller in Unity

Overloading methods in C# & Unity

Modular Health System in Unity!