All right.
Welcome back.
Now let's go ahead and create a high score.
You probably know how to do that.
So please go ahead and try that.
Just try to do to create a high score.
Add a high score to the game.
All right.
I hope you tried it.
So I'm going to duplicate the score and I'm going to call it high score text now.
High score text.
Now in the game manager, I will have to change some things.
So let's go there.
Let's add a new text here.
Public text.
High score text.
And I will need an awake method here because at one point I will need to get the high score from our
player press.
So let's go ahead and create one here.
Private void.
Awake.
Get high score.
Now, what we'll need is, of course, a get high score method.
So public int get high score.
And what we do here is we set I create a new variable called I and we get the player press at the position
get int high score.
And now you might say, hey, there's nothing, there's nothing in there.
How could you get that?
Well, we will set it up in a second.
So what would be a good position to set the high score?
Because here we only get the high score from the player press.
So from our little storage, we can store minor data.
A good point would be when we increase the score.
So in here we should check if the current score is higher than the high score.
And if that's the case, please go ahead and set the score.
So how do we do that?
We can simply check here.
Score higher, then get high score.
And if that's the case.
You just play a press that set it.
And here we need two values a string, which is the key and the value that we want to set there.
So the key is high score and the value that we want to set is score.
So we simply set the score here.
Well, that's not enough, because we also need to assign the high score text text property with our
new value.
So score to string.
And now that we have that, we can go ahead and get the high score on a wake.
So let's get the high score text to text and set it to best colon.
Plus get high score to string.
All right.
So let's check that out.
Let's go back to save the script.
Save the scene, by the way, and run the code.
So let's get some points.
Enter.
Actually I have a null point of reference, of course, as the game manager doesn't know the high score
text yet, so let's grab that in there.
Now we can go ahead and run the game again.
So now let's see.
The score is not perfectly.
The high score is not set at the perfect position.
So maybe let's change that.
Let's move it down to -150 or maybe 120.
Yeah, -120 should be fine.
And maybe let's scale it down a notch.
So let's go to, I don't know, maybe 70.
I think that should be good.
Now, let's try it again.
That we are best zero.
Now let's press enter.
And now, as you can see, the two was stored and now our best score is two.
Let's run it again.
Let's try to get three points.
There we are.
Our best score is three.
Now, you might say, okay, best three is set up there.
Now, maybe we should set it up in our method as well.
So.
Let's go there.
Because here we just say.
Set.
Score to string.
But what we should do here is maybe best colon, empty space plus score to string.
Now the best colon will be set up and shown all the time.
So if we get points, we should still see it.
All right.
Well, unfortunately, we can't get more points now because we don't have more crystals on the game,
but we will fix that later on.
Great.
So I hope you manage to do that.
And in the next video, we are going to add a crystal effect.
So see you there.