Solution to the lack of flexibility in Collection file and Game Object file

I’m just writing this down as I felt. Don’t take it too seriously. :grinning_face:


Background

I previously created a canon_enemy that can fire projectiles using a collection file. Today, I wanted to give this canon_enemy the ability to move vertically in certain scenes, but the collection file simply can’t do that because modifying the canon_enemy in one scene will modify all canon_enemy in all scenes.

Of course, I can solve this problem by creating a new collection file called canon_movale_enemy.But when I need to add more functionality to the canon_enemy, I’ll be forced to create more and more collection files.

However, I later discovered that modifying the script properties of certain instantiated Collection files individually is also a good solution.


Solution

The drawback of a Game Object file is that it cannot contain Game Objects; it can only store components.

However, modifying the script properties of a instantiated Game Object file will not affect other instantiated Game Object files.

Although a Collection file can hold multiple game objects, modifying a instantiated Collection file in one scene will also modify instantiated Collection files in other scenes.

However, modifying the script properties of a instantiated Collection file will not affect other instantiated Collection files.

My solution is to put all prefabs into a single Collection File. When a scene needs these prefabs, I manually copy the corresponding prefabs from this Collection File to other scenes.

This solution reminds me of the Contruct3 game engine; I remember seeing something similar when I watched a Contruct3 video tutorial a year ago.

Then I thought of creating a collection file to store custom “components”. These components could be scripts or Game Objects. Some custom components could implement vertical movement, while others could implement bullet firing. These custom components could then be freely combined and placed elsewhere.

I’m not sure I understand this part. Instead of storing game objects/components as files in the project structure you create them inside a collection? And you copy-paste from this collection to other collections?

1 Like

Yes :grinning_face:

What problem does this solve? Is there any advantage over having files?

1 Like

Actually, I later realized this isn’t very useful :joy: . Maybe in certain specific scenarios it has a slight advantage over having files. :thinking:

If you have a templated structure that you need to recreate quickly, I would suggest looking at editor scripts to automate that.
A collection is just a text file.

1 Like

Thank you :grinning_face: