‫All right.
‫Welcome back.
‫Now let's go to the asset store and import the crystals because we will have crystals that we need to
‫collect.
‫A very nice asset for that is stylized Chris Tull.
‫So let's search for that.
‫We can find it here.
‫Low poly or low li poly.
‫They have created great assets for free, as you can see.
‫So let's go ahead and import that.
‫Let's download it and import it into our game.
‫All right, now let's create a crystal prefab out of it.
‫So let's go to stylized crystal.
‫We can find a crystal here.
‫So I'm going to drag that into the game.
‫As you can see, it has an animator.
‫We won't need that because we don't want the crystal to be animated.
‫So let's remove that.
‫Component.
‫Now let's change the name to Crystal.
‫And let's add a box collider So physics box collider And then we set that to trigger.
‫So it's trigger we set that to true.
‫So as soon as we collide with that one, we want to add a point to our game.
‫Now I want to add a tag to this crystal.
‫So let's add a new tag plus and let's call that one crystal.
‫And now let's go to the crystal again and select that tag.
‫Right now, let's create a new folder called Prefabs, Create Folder Prefabs and drag the crystal into
‫our prefabs folder.
‫All right, next, I would like to rotate it a little bit and to change the position.
‫So let's change position to 000 for our crystal.
‫Actually, for that crystal here.
‫So 000, as you can see now, it's at the bottom and the Y value I want to have is 0.5.
‫So now it's just on top of our road and now we need to change its rotation because now you see it has
‫no rotation, but that's local.
‫So if we go to global and change it, well, actually I want to have a rotation of 45.
‫So now let's go to local again and we can move it around again with shift command.
‫We can position it correctly.
‫So now let's save that setting and let's apply it to our prefab and now we can go ahead and duplicate
‫it.
‫So let's duplicate that crystal duplicate and let's move the duplicate, let's say around here and you
‫can play around with the values you could, for example, position one here and then duplicate again
‫and position it just at the edge so that it's quite difficult to get it and you risk of dropping or
‫falling to the ground or dying and losing the game pretty much.
‫So you could do that and make it a bit more difficult.
‫Now, the next thing is, I don't want to have a bunch of crystals in my game.
‫What I do want to have, however, is a folder.
‫Well, I want to have them in a game, but I don't want them to be in the hierarchy just like that.
‫I want them to be in a crystals folder.
‫So let's drag those crystals into our crystals folder.
‫Now.
‫Let's check it out.
‫Let's see if we can walk through the crystals.
‫And we can see we can walk through the crystals real quick and perfectly so.
‫Now if we walk through them, we of course want them to disappear and we want to increase our score.
‫There's one little thing that I would like to change before we do the crystal implementation even further.
‫So there is one thing we can still do.
‫We can still change the rotation of our game before we start the game so we can move our player to the
‫left.
‫And if I press enter now, that's not really great behavior.
‫So what we can do now is we can go back to our script, to our chart controller to be precise, and
‫within the switch method, we can go ahead and check if the game manager thought game started is false,
‫then we just want to return.
‫So that means we will do nothing of those switching.
‫By that I mean changing the rotation of our player.
‫So now let's check that one out.
‫So before the game starts, as you can see, I press my space key and nothing happens.
‫As soon as I press enter, however, I can do the rotation.
‫All right.
‫So now let's go to our game manager, because we need to have a score.
‫So let's create a public int called score and we will need a method to increase the score.
‫So public void increase score and we simply will increase the score by one.
‫Nothing too fancy.
‫As soon as we run through an object, we want to increase increase the score by one.
‫And when do we want to call this method?
‫Well, in our character controller and there we will need an on trigger enter call.
‫So we need the method on trigger enter.
‫So as soon as we collide with something and that something so other dot tag is equal to crystal, then
‫we want to destroy the object.
‫So destroy our other game object, which means we will destroy the crystal.
‫And then we want to increase the score, which means we call the increase score method.
‫All right, so let's try that and what we will not see.
‫Well, we will collect those objects, so let's press enter.
‫As you can see, we destroy the game objects, but we don't see the score yet.
‫So for you, a little challenge.
‫Please add a UI element to the top left.
‫So just a number showing us how many points we have.
‫So just show the score on the top left side.
‫Try that.
‫Please go ahead and do that.
‫All right.
‫I hope you tried it.
‫So let's create a new UI text in our hierarchy.
‫Now, as you can see, a canvas is created for us.
‫Now let's click on the text variable.
‫I want it to be at the top left.
‫So I set an anchor to the top left.
‫Now let's set the position to, let's say 100 and let's go with zero.
‫Now, just to see where it goes.
‫Then let's change the font size to let's go with 50 the color.
‫I want it to be a white text.
‫Then as a horizontal overflow and the vertical overflow, I'm going to use overflow, which means it
‫will go outside of its size, which is height 30 if it needs to.
‫So if it needs more space, then it will simply take the space.
‫And now let's set the number to zero and let's see how that looks in our game.
‫All right, there we are.
‫So maybe zero is not the perfect Y position.
‫So let's move that a little bit.
‫Maybe two -50 or maybe -20 is enough.
‫All right.
‫And the X position.
‫Let's go with 100.
‫Maybe the font size should be a bit higher.
‫So let's go with 100 here for the font size, you could of course use a different font.
‫I'm just going to use Arial for now.
‫And yeah, I think that should be good.
‫Now let's see what happens if we start the game and we try to score.
‫Of course nothing happens because we haven't implemented it, so I hope you try to implement it as well.
‫By the way, let's change the name of the text to score text just to show that the names are right now
‫in our game manager.
‫We will need to change some things.
‫We will need to have the text.
‫So that means we need using unity engine UI in order to access the text class.
‫And now we need a public text score text.
‫And with an increased score we also set the score text that text variable or text property to score
‫dot to string.
‫So that means we transform our score value, which is zero at the beginning, and then it goes up and
‫up.
‫We convert that to a string.
‫All right.
‫So let's save that script.
‫Let's go to our game manager, because now our game manager will also need a text after a little while
‫so that we are score text.
‫Now let's drag that score text in here and now let's try it again.
‫Enter.
‫And as you can see, we're collecting points.
‫Perfect.
‫In the next video, we are going to have a look at setting up the high score.
‫So we want to know what the high score is, how far could we go?
‫So see in the next video.