Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

I'm following the Brackey's 'How to Make a Video Game' and am having trouble..

In some videos, he suggests that we can make prefabs for the ease of changing settings on multiple levels by keeping a prefab of everything...I didn't quite understand the concept. Please Heelpp!

Answers

  • I don't quite remember the tutorial and I don't have the bandwidth to watch it again. But, once you make an asset in the scene and then drag it in to the folder view, it becomes a prefab. You can now drag the prefab into multiple scenes and they will become 'instances' of the prefab. When you edit the prefab from the folder view, all instances change to reflect those changes. But when you edit an instance the other instances are not affected.

    A good use case scenario would be when you want to make different characters and want them to share some aspects. Or maybe your character has a spell that decreases the size, defense, attack and health of the type of enemy it struck. You can tell the script to get the prefab and apply the changes to that prefab. If however, you are not using prefabs, then Unity will treat all the enemies as different game objects. You can of course get around it with tags but they still won't be connected.

    It is a good practice to use prefabs. Who knows, maybe halfway through developing the game you find yourself wanting to change the scale, or scripts on a specific type of assets, if you have instances of prefabs you will only need to apply the changes to the prefab itself rather than applying them to every object individually.

Sign In or Register to comment.