Learn to code by making a 2 D space shooter game.
Objective: Implement Score System.

To get started let's create a new script called UIManager and attach it to our canvas.
The first step lets create a variable inside the Player script to define our score and give the value.

Let's create a method inside Player that will be responsible to add scores when we kill the enemy.

Now we need to call this function when we kill the enemy, inside the enemy script we get a score when we shot the enemy. Remember this function passes a parameter of int so you need to pass a number of scores there.

It's time to update our UI inside our UIManager, but to do these we need a reference of our text component in order to be able to manipulate it or update it.
So when the game begins we need our score to be zero so make sure to append a zero afterword score.

Note: if text component doesn't appear in IntelliSense make sure to add,
using UnityEngine.UI;
Now it's time to update our UI when we kill the enemy, Let's create a method inside UIManager with parameter.

We need to call this function inside the player so when we add a score to the player we Proportional update the score to the UI.
We need to communicate to UI to access this method and cache the component we are looking for.


Now its time to call the update method in Adding score


This is how we Implement a score system, see you in the next article