Whats the correct way to handles instances?

In the video I saw that I can make multiple instances. Lets say I want to 50 of them, I need 20 with the default values, 10 with different size, 10 with different color, also 10 with different gravity.

So I should create multiple scenes for that? Or do 1 scene and make changes accordingly? Can I group the instances to see whats different?

Most of the time, you’ll want just the one object scene and make whatever changes you need from a design perspective - this is the strongest use-case for export variables, since they work per-instance and you can set the values from the Inspector.

All of the example changes you listed above are good situations in which to do this; however, if you’re making a new variant of an object scene (for example, those 10 with different gravity all have the same gravity), then it might make more sense to make a new object scene so that this new object can simply have different default values.

There is a better way to do this called inheritance; it’s not something you’ll need to do at this stage in the course and I don’t want to bog this down with too many extra details (I think inheritance is introduced late into Alien Attack). The short answer is that the export variables should be enough for a while yet, and there are more advanced things you can do later as your needs become more complex.

Groups can be very useful for performing logic, but if you just need a way to keep the scene tree tidy, you would be better off using additional Node2Ds as “folders.” White Nodes are even better, as long as their lack of a Transform doesn’t break anything (if it does, just use Node2Ds instead).

2 Likes

Privacy & Terms