How to organise scenes for different enemy ships

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By wallasaurus

So I was googling and experimenting and doing various things so far, but I thought I would ask the experts for some context.

I have some different enemy spaceships. At the start I thought just different sprites and some stats would be all. For this I learned about the custom resources, and made one for ‘enemy data’ and this works well for the stats and sprite index for the animated sprite.

However, as I tinker and develop things, I realise there are some other type of things I would like to change. Various stuff that is beyond just stats, but to take a concrete example, engine locations. These are for the engine sprites to be placed and activate based on movement inputs.

At the moment they are just there in the ‘enemy’ scene, and there’s a bit of logic in the script to do the right things to them. If I continue down that naive path, there will be many of them, and lots of logic, and the workflow will be annoying too.

So I realised there are probably a bunch of ways to do this, but I wanted some ideas from experts.

I was thinking, what if I break out the ‘engines’ thing as its own system and have it as component of the enemy scene or even the enemydata resource. that might help control the logic stuff from bloating. But I don’t see how the workflow would be.

Maybe there is a way of having different scenes completely for these different kind of enemies, but use the same script - that makes setting up the locations of things on the scene easy, but maybe logic in the script would get bloaty after a while - it doesn’t seem right.

Anyway, rambling now - I’d love any ideas anyone has for this - it will doubtless come up again for me in other things so it would be super to learn from your expertise.

thanks, cw

This really is up to you. I wouldn’t want to dictate how to write your game, or even consider myself an expert; this is highly-specific to how or what you’re trying to achieve. Certainly don’t be afraid to ‘fail quickly’ and change direction if need be. Perhaps fire up another project and isolate what you want to do before creating a component in the game.

One approach to consider is taking a node reference (or an array of references) in some controller and you drag and drop the nodes into the export variable. The ‘engine’ component can wrap the references and expose the necessary info where necessary. I’ve done this for weapon components recently.

Even just having components and leveraging ‘Editable children’ may help; a trade-off compared to writing a component if it’s just a single instance.

spaceyjase | 2023-03-30 15:44