Pretty much every game has some sort of scoring system. You will now learn how to write simple code that calculates the score based on the distance the player has traveled since the start of the level. We will then use this score value and store it in Unity's PlayerPrefs class to make sure that the value is remembered between sessions. PlayerPrefs is a very useful built–in Unity class that allows us to store and access data between Unity sessions.
Let's write the following method in the Player class:
We have finally come to a real–life example of a method that returns something. As you can see, the GetDistance() method returns a float value, the distance between the starting point and the current position of the player game object.
I won't go into too much detail here. I encourage you to dive into the Unity...