Nerd For Tech
Published in

Nerd For Tech

Creating Collectables in Unity

Objective: Create items the player can pick up and collect.

First we’ll make sure our collectable item has a Collider component and Is Trigger is checked. We’ll also need a Rigidbody component, and will probably want Use Gravity unchecked, unless we want the collectable to fall to the ground.

Now we’ll create the Collectable script to attach to our collectables. We’re creating coins in this case, so we’ll give them a _value that can be assigned in the Inspector. In this way, we can create coins of different denominations.

When the player touches our collectable, the collectable will call the UIManager’s AddCoins method, passing-in the value of the coin. The collectable will then destroy itself. If we wanted to add particle or sound effects to the pick-up, we would place them just before the Destroy command.

The UIManager’s AddCoins method adds the coin’s value to the current count, then calls its UpdateCoinDisplay method, which updates the text with the new count.

In a more complex game with more collectables, we might use a Game Manager to track the items collected, and have it tell the UIManager what to update.




NFT is an Educational Media House. Our mission is to bring the invaluable knowledge and experiences of experts from all over the world to the novice. To know more about us, visit

Recommended from Medium

Twin Tiers Cinderella

Best Machine Learning Training In Jodhpur | OilabLearning

Linting your Ansible Playbooks and make a Continuous Integration(CI) Solution

Image Recognition, Auto-Tagging and Machine Learning — Plus Crayons

See how SLOs and error budgets enhance app reliability

CS371p Spring 2021 Final Entry

Pioneering New Tech: Kirk, Picard, and The Borg Collective

How to get Nouns from a Sentence in Python

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
Ryan Sweigart

Ryan Sweigart

An independent Unity Developer.

More from Medium

2D Game Development: Colliding with Colliders

How to stick decals on the Spatial Mesh of Hololens2

Publishing to the Google Play store

2D Mobile: Setting Up The Player