Creating Collectables in Unity
Let’s create a UI manager that shows the coin’s amount
Process
Coin
- Add a
Rigidbody
to the Coin gameobjects and set theisTrigger
value to true

- Add a
Coin
script to them a with anOnTriggerEnter
that checks ifother.CompareTag(“Player”)
- If so, call
UIManager.Instance.UpdateCoinsDisplay()
andDestroy
the gameobject
UI Manager
- Create a
UI Manager
script and add it to a Canvas gameobject - Create a singleton
- Declare an
int coinsAmount
and aText coinsText
- Create a method
UpdateCoinsDisplay()
that will increasecoinsAmount++
and update thecoinsText.text
