Creating a Collectible Coin

Going over how I implemented a collectible coin in my 2.5D game

Objective: Create a coin collectible for my 2.5D game.

Animation and VFX

To get started, the first thing I did was grab a simple coin model from CGTrader.com. This is the specific model I am using.

Once downloaded, I brought the model into my project. I then created a simple float animation, as well as gave my coin some simple VFX.

With that setup, we can now go about implementing the functionality.

Functionality

First, I went ahead and created some text UI so we can see the count increase when our player collects a coin.

Next, I simply re-used some code I built before when prototyping my 2.5D game. This is the UIManager Code I am reusing:

In my Player class, I added a private int variable named _coins to keep track of the coins the player currently has. I also created this method below:

This script is called in my CoinController class, which is attached to each coin GameObject.

CoinController script

This gave me the result we see here:

That’s all for today! Thank you for reading! In the next article, I will create a ladder system.