- Home /
Master objects with preset connections to scene objects?
I'm building an arcade game with a single scene for the whole game, and just adding enemy objects in waves. The project has prefabs so that I can use them in the Title/Attract scene, but that's the only reason they're prefabs in my case. In the Game scene I've created single "Master Instances" of these objects which are inactive by default, and I clone them to create the enemy waves. The scripts on these objects have several public properties that are pointed at other objects in the scene, such as the main Game object (which spawns waves, handles scores, etc.), the Player Ship, Audio Sources, and any other Master Instances that they may need to Instantiate later, such as explosions and bullets. I created these Master Instances in the scene so that their object references will automatically be set on Instantiate.
Does this sound reasonably sensical? I wanted to avoid loading prefabs, which is slower than cloning existing instances, and it's really convenient to have these connections already established without needing to set them in code. It seems like this is a proper way to do things, but of course it does requires a little extra RAM for the convenience of having local pointers. I welcome any comments and advice surrounding this approach!