Script of prefab in scene, but not asset

So, I noticed when dragging the Movement script onto the Rocket… it only exists on the Prefab in the scene, but not on the master Prefab in the Assets folder.

In my mind, this could get confusing since you may lose track of things like this.

Is that intentional, or should it be best practice to make sure update the parent prefab asset in this case?

And in what case should we not?

Hi Bill,

Prefabs do not exist in the scene. Only game objects exist in the scene.

When you drag the Movement script on your Rocket in the scene, the prefab does not get updated automatically. You have to explicitely apply these changes to the prefab. Click the “Overrides” button.

This behaviour makes sense. Imagine you have an enemy prefab, and you create 100 game objects with this prefab. When experimenting with one of the enemies, you usually don’t want to change all of them. When you are happy with the result, you could either create a new prefab or apply the changes to the prefab, so all enemies get the same values. If you are unhappy with the result, you could simply delete the manipulated enemy without having to worry about the prefab or the other enemies.

Did my explanation make sense?


See also:

1 Like

Hi Nina!

Thanks! And yes I do understand the mechanics of it, however I think I have to disagree then with Rick’s recommended practice of “prefabbing” everything. If you are only to have 1 instance of a game-object, and you run the risk of making changes to it thats could be lost if you delete it, and make a new one from the prefab… I don’t know, seems all too easy to make a mistake!

I was going to say something similar to what Nina did, but then realised you may be talking about a script that should actually be on the prefab. I don’t have the 3d course so I couldn’t double check, but from my understanding Movement is crucial to the behaviour of the rocket and without it you have a silo. I would therefore hazard a guess that the Movement script should in fact be in the prefab. You can simply apply the override and it will add itself to the prefab

1 Like

Did Rick really say that we should prefab everything? If so, I agree with you. That does not make much sense. He probably meant to say that we were supposed prefab things that we want to reuse in our game.

The goal is to create multiple levels. For each level, we create a new scene. Instead of recreating the rocket in each level, we simply drag and drop the rocket prefab into the scene. We also need a launch pad and a landing pad in each scene.

Of course, the rocket prefab should contain everything the actual rocket in the scene needs. As bixarrio wrote, the rocket prefab definitely needs the Movement script because we always want to be able to move the rocket.

2 Likes

Yep, it is a little confusing but I am glad my thinking is aligning with what you seem to be saying here! In my mind, I would only prefab things of which I want to use multiple identical (mostly) instances of in the scene. But if I have 1 object that will ever and only be 1 object, I don’t think I would prefab it.

Later in the course, Rick did go back and add a note that we should keep the prefab updated with any changes we make to the instance… but again if we’re always just going to have “one” of them, seems like wasted work to prefab and then manage it.

But, I’m new, so I have a lot to learn and may understand it better later!

Also thanks @bixarrio !

I think you understood the concept of prefabs correctly. Feel free to apply your knowledge as it makes sense to you. :slight_smile:

Since this course caters to beginners, Rick probably did not want to confuse his students with additional information when he taught how to create and use prefabs. Furthermore, he teaches his own way of developing games based on his experience. There is no right or wrong in this respect as long as the problems get solved. When developing your own games, you’ll very likely develop your own way to approach and solve problems.

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms