Okay, so I've deleted all the triangles out of this scene, and I'm just going to drag the triangle back into the scene. So you'll see here that the triangles at 00, point two, seven and zero. So you can see, I think it was before it was a little bit low. So I'll just bring it up to 0.27 might be different for your, your project, but just make sure it's like sitting flush with the ground just so it looks nice. And so we have the triangle right here. And let's just bring it forward a little bit.
And let's turn our play back on. And let's see what happens when the player runs into it. Okay, the play goes straight through as not good. So what we want to do is we need to look at the triangle and see what's on our trial. So we've got our mesh filter, we got a mesh renderer on which renders it to the screen. And we basically that's basically it, we don't have anything else.
So what we want to do is we want to add a mesh collider so you can just type in mesh colada, you could use Say for example, square kilometer if you wanted things to be a little bit simple um, but this should be pretty good because it's certainly a triangle. So then if we press play now you'll see what will happen. Cool, our player goes over the top. That's pretty awesome. So because our world is always flat, we never ever want our player to be able to move up or down. So you can actually go over to our player, go down to rigidbody, we can open up constraints, and we can actually freeze position on the y axis.
Press play again. And you'll see it's just rotating in spot there because it can't move up and over. And that's exactly what we want. Fantastic. So now we have a triangle. Well, how do we use them to create randomness?
How do we use them to create the game that you guys saw at the beginning, the game the finished the finished project? Well, we need to actually create a few different pre-fabs a few different instances. So we have a generic triangle here, that just is all great. But we need to actually create like sets of triangles like a grouping of triangles and then use them as prefabs. So how we're going to do that is let's turn off our player again. And let's turn our triangle.
Let's bring a triangle back to zero in the z axis, so it's right in the middle. Let's just bring it here. Just like to position the camera a bit better. So we can see what was going on. And let's get a triangle. And let's copy it and paste it.
And we're going to put this one at position two, and we're going to put this one at position negative two. So then we've got a gap through the middle. Awesome. So then we also want to create an empty and we want to make make sure you zero this empty out. 000 and we can call this triangles underscore a. And we can grab these two triangles, which if they're at the perfect position, drag these two triangles into triangles a triangle, a should be at 000 for everything, and then we should have negative two, then two.
And then we'll be able to actually drag this, you know, we can drag this forward and back. You can do whatever you want with it, you can move it off to the side, but now it's grouped together. Well, that's awesome. But we also but what else do we need? So we need Okay, so we've got the two colliders here. So that's all great.
And we want to actually tag these triangles with a special tag. So when we run into them, we can actually, you know, create a game over screen. So if we click on one of the triangles, and we go up here, and we click on the tag, and we click open tag, we click the tag button here and click Add tag. We can have a list of tags here, we can click the Add button and we can call it triangle with a lowercase t, triangle. And then we can go over to our two triangles, and we can set their tag to triangle. We can go to a prefab we can set that tag to triangle.
And so now whenever we run into it, we can actually access this through code. And we can ask the question, Hey, have you run into something with the tag triangle, and then we can use that to form our game logic. So the only other thing we need to do is we need to create a center section. So the center section will be where we get the score. And we just want to make sure so whenever the player passes through the center section, he gets one or she or he gets one point. So what we can do is we can create a new 3d object create a new we can actually let's create a new empty let's grab this empty 00 Zero make sure it's absolute center, we can call this gap.
We can drag this gap on to triangle day. Once again triangles, they should be at 00. And all these should be negative two on the x two on the X and 000. So it's right in the middle. Then all we need to do is add a box Collider. And you can see here I'm not sure if you can see because it's also green.
But you can see here we've got a, we have a box Collider. Now all we need to do is click is, is trigger. And then let's see what happens. So if the player runs into the section, that's fine, but it still can go through the center. The reason it can go through the center is because we've turned his trigger on if we didn't turn his trigger on. The collider would act like a colada.
Bam, we ran into the colada, but because we've turned his trigger on, we can pass right through it. So we'll use another separate line of code to say, are we in the Trigger Zone gap. And if we are, give it a point. And so that's how we'll form our game logic. And the only thing we want to do is we want to add a tag to this gap section. So we can go over to the tag section, add tag and added a tag and we can call call it call pump.
Cool. And then make sure you assign it to score up. And then all we need to do is we need to make sure this is at zero is we can just drag this whole parent object here into the prefab section. And then we have our own. We can get rid of it now and then whenever we drag it in, we have our own prefab sort of area that will give us a score and we can run into These two enemies we don't have any of the logic coded in yet, but this is how we how we will be going forward with the prefabs. So we've created one prefab, but we actually need to create two more prefabs.
And I'm pretty sure you guys will guess how we're going to do it. Let's just do it really quickly copy paste, and we can paste it again, let's open up the triangle, so we got one at negative two. Let's add this make make this one zero. Let's turn off this one, sorry and turn off this one just so it looks so you can see what's going on. And we need to make our gap at two. So then let's turn off our player as well.
So then we have a situation where we have the two triangles on the left hand side and we have the cube here, so that's fantastic. We can call this triangles B. Drag this in. Done. Now we can get rid of this Get rid of this. And we can do the same thing here, turn it back on, we can go triangles at two, triangle at zero.
And we can make the gap. Make it two. And then we can call it triangles. See. Awesome. So then if we delete this, you'll be able to see if we drag this in, and then we drag this in and then we drag this in.
Make sure these tend to play back on. We can press play, and the player can move through these sections. We need to make sure that all of the gaps, let's just go to gap is trigger gap is trigger. And gap is trigger, press play. Man we can pass through, and everything works fine. Cool.
So we got a basic scenario here. So let's just, I'll just drag this up. So we got a BC. Let's put this one at, say, let's put a 20 on the Z. Let's put B at 40. And let's put C at 60.
So if we press play, let's see what it looks like. Cool, so would you get a score there? We get a school there. And we get a school day unless we bumped into them. So So in the next episode, we'll be coding the functionality of these gaps in these triangles. What happens when you run into a gap where we want the score to go up.
So in the next episode we'll be coding the logic or the functionality behind the prefabs that we just created. See you there