Want advise for designing flexible Children Nodes in a Child Scene

Godot Version

4.3

Question

Imagine a vehicle game that has multiple playing stages with many customizable vehicles that could switch multiple weapons and various vehicle parts around. Each weapon from a cannon to machine gun to flamethrower would all function differently. The cannon shoots a big shell. The machine gun rapidly shoot out smaller bullets. The flamethrower sprays out flame in front. Different vehicle wheels could be useful on different terrains they designed for. Etc.

Now, I am trying to wrap my head on the intended way to do the above in Godot. If I have designed a vehicle scene and then in the stage scene, I put several vehicle scenes into the stage scene, I see that a vehicle scene only has itself without its children nodes. And then here is where I would like to ask for advise.

One way I could think of is a vehicle scene should have wheelTypeNode, weaponTypeNode, chassisTypeNode, and in the vehicle scene, create variables for “which weapon does it have”, “which kind of wheel does it have”, etc. In the stage scene, set variables of each instantiated vehicle scene to be whatever I preferred, and during the initialization function of the scene, set the required attributes accordingly with respect to the variables such as putting in 3D model of the respective weapon on to each scene when the stage scene runs. Is this normally the way to go? But then when I do this, I think I will not see each vehicle’s weapon type used on the Godot’s 3D window. This becomes a bit hard to manage as I have to look into the variables of each vehicle.

Is it possible to make it so I create a vehicle scene first, then in the stage scene, I could make it so each vehicle scene could have different nodes accordingly such as different 3D models for the wheel, weapon, etc. along with different nodes/scripts as required. And make it so their respective 3D models are also shown right on Godot’s 3D window?

Normally, how do we manage such “customization” in this case?

I think this is a good way:

  • Create a node for each parameter in your vehicle
  • Create node’s children so that it has one child for each parameter value
  • Create a script in the vehicle that manages the children of each node according to the parameters

But then in that case, I will still not see the relevant 3D models or the like on the Godot’s 3D window, right?

You can, because the script is only activated at runtime and makes the additional models invisible and the main model visible, you can still manually change their visibility to work on it and not worry.