Creating Collectables in Unity

  • Add a Rigidbody to the Coin gameobjects and set the isTrigger value to true
  • Add a Coin script to them a with an OnTriggerEnter that checks if other.CompareTag(“Player”)
  • If so, call UIManager.Instance.UpdateCoinsDisplay() and Destroy the gameobject
  • Create a UI Manager script and add it to a Canvas gameobject
  • Create a singleton
  • Declare an int coinsAmount and a Text coinsText
  • Create a method UpdateCoinsDisplay() that will increase coinsAmount++ and update the coinsText.text

--

--

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