Challenge: Create a score system within our Unity game.
Currently, while we have basic elements, our game lacks any sort of HUD to let the player know what their score is:
To fix this, we are going to first add a UI element (Right Click > UI > Text):
We will also make an empty game object with a script attached to it, in order to manage our UI. Within this script, we need to enable the UI elements within UnityEngine:
This will allow us to create a text handle in our UI manager:
which we attach our Text object to. Within the UIManager script, we set the score to set to 0 when we start:
and set up a method to update the score:
Finally, we set up the code that will call our UpScore method when an enemy is destroyed: