So back in unity, we can see that we can like instantiate things like we can, you know, create things like cubes or spheres or things like that. But what if we want to create like say a enemy that just pops into existence or something like that? Well, we actually need you know, an enemy is got an animations and scripts attached to it and all these different things. And we can actually combine all those things together into what we call a prefab. So what a prefab is is basically a combination of all the elements that you know an object needs, and then you can instantiate or create or spawn that thing into the world. So to give you an example, let's just delete this cube because we don't need it.
Let's create a new folder called prefabs. And this is just for organization sake once again, and open up the Prefabs folder. Actually now let's let's go back and let's open up the models folder. And we have this model here called triangle. So if we just drag this triangle into To the hierarchy over here, it'll pop up around dislocation. So what we can do is we can just drag it for a little bit, we can change its y position to zero, we can change this to negative 90, because that's what I think trying to do.
And, in fact, let's remove, let's get the triangle and let's bring it back down to the player level that's about the size we want. And let's press two. Awesome. So I think that's actually a good good size and location for the prefab. So right now that the prefab has on it, a mesh renderer and it's got a certain material and what we want to do is we want to go over to materials and we want to create a new material For the we're going to create a new material for the triangle. So create material triangle.
And we can change the color. I'm just going to use like a dot bright because I think that looks good. I think that looks. I'm just gonna use a dog, right because I think that looks best. And then if we go over to triangle, we can then obviously drag the material. So it looks like that.
I think that looks pretty good. So what we want to do is we want to just turn off the player for a second, and we want to get the triangle and we want to put the triangle at 000 rotation should be negative 90 so it rotates like Mandela wasn't it, we could have it like this or something, but we're not going to do that. Just give it a negative knighting scale at 100. All these things look good. These are all the data thoughts. And then what we're going to do is we're going to go over to the Prefabs folder and we're going to drag in triangle.
Cool. So this is a prefab of our triangle. Now what we can do you can see is turned blue here, which means that anything that we do to this you can click apply and it will plot this prefab, or anything you do this prefab will affect this. So for example, if we decide to change the texture to the water texture, it actually is going to change each instance of the prefab. So let's like let's try a few more in here. Let's cool so we got a bunch of different triangles.
Now we go up we can go to the proof of the triangle prefab instead of instead of changing the texture, the color on all these different triangles, we can actually just change it on the prefab. We can change it to whatever color we lack So that is what a prefab does and that is what a prefab is. In the next episode we'll look at how to use prefabs to create randomness