HomeUnityHow to Make Prefabs in Unity

How to Make Prefabs in Unity

Prefabs is short for prefabricated objects. When you completely give a game object its required behavior, you have fabricated it into a working model. To use the same game object again in your game, you can’t just duplicate it in the hierarchy. In fact, unity has an option for you. Check out this Tech-recipe, How to Make Prefabs in Unity

If you have been reading our previous tech-recipes you probably know that I developed a graveyard game in a semester project. Now, there were game objects that we used at many places in the same game. For Example, we got a model of a grave from the internet. We applied animations to it, to simulate grave digging. Later we attached a red point light to it.

After we were done giving the grave all this behavior, we added it to the folder of prefabs. We needed to put that grave at many places in the graveyard. We wanted the grave to behave similarly every single time.

What putting an object into the prefab folder does is, it saves the object with its behavior/ opponents. So even when taking the gameobject to other games, it will behave the same. But you might end up losing some stuff about it. But the game object will behave the same.

Can we find prefabs on the internet

You must be wondering oh! that makes game development a 100 times faster. But that’s not the case. Yes, you can download prefabs off the internet, extract its materials and textures and use it. But you always have to scale it or add more behaviors to it. But prefabrication is a unity blessing.

Can you edit prefabs

Of course, you can. Just make sure you edit the prefab from the prefab folder. Some times you end up editing a variant of the prefab in the hierarchy, varients of the prefab can be planted as well.

Prefabs enable respawning

One of the greatest things that prefabrication enables you to do is respawning. Bullets, zombies or any character that needs to reappear in the game, should be a prefab. The prefab then can be scripted to respawn in the game, can be made to disappear from the game as well.

How to Make Prefabs in Unity

Step-by-Step procedure

1. Provide the game object full functionality. All the scripts, components such as meshes, audios,joints, etc.

2. Make a prefab folder.By default the older is present in the project folder.

3. Just drop the object in the prefabs folder. And delete from the scene.

4. Drop the object again in the scene, now from prefab folder.

Check out these tech-recipes

How to Add Audio in Unity | Unity 3D Game Development

How to Pick Objects in Unity | Unity 3D Game Development

Use Joints in Unity | Unity 3D Game Development

How to Use Material and Physics Material in Unity | Unity 3D

How to Use Lights and Cookies in Unity to Beautify the Scene (Part 2)

Add Trees and Windzones to Simulate Air in Unity

How to Move the Player in Unity | Force and Physics in Unity

Joudet Ahsan
Joudet Ahsan
SEO Content Creator, a Computer Scientist in making and someone who sucks at writing bios.


Please enter your comment!
Please enter your name here

- Advertisment -

Most Popular

Recent Comments

error: Content is protected !!