Creating the score system
We want to be able to assign a point value to each enemy and have a visible score increase with each kill. This goal can be split into two tasks: first, we need the UI to display the score and second, we need logic to track the current score and push any changes to the UI. As the second task (the score logic) requires the UI, we'll start by creating an interface to display the score before moving on to the logic.
Implementing the score UI
UI is an acronym for user interface and refers to all the 2D graphical elements that sit atop the game window and provide information to the player:
- Create a new UI Canvas object by selecting GameObject | UI | Canvas from the application menu.
- The Canvas object defines the total surface or area in which the UI lives, including all buttons, text, and other widgets. Initially, the Canvas object may be too large or too small to be seen clearly in the viewport, so select the Canvas object in the Hierarchy...