Collisions for Characters with Multiple Parts

Godot Version

v4.3.stable.arch_linux

Question

I’m trying to remake and old project of mine now in godot, to learn the basics.
What i’m trying to achieve is a modular character (in this case a tank) where different parts of the body are separate scenes and are then placed into the actual CharacterBody3D scene. (In this case I would like to separate the Turret and the Base of the tank.)

The reasoning behind this is that for instance I would like to have the turret responsible for the “shoot” function. That way I could create different versions of turrets with different abilities and easily swap them out to create new enemies, or player vehicles.

The problems now are the following:

No Collision Mesh Set

If I strucure the Tank as

- Tank (CharacterBody3D) 
-- TankBase (StaticBody3D)
-- TankTurret (StaticBody3D)

- TankBase (StaticBody3D)
-- BaseMesh (MeshInstance3D)
-- BaseCollision (CollisionShape3D)

- TankTurret (Same Structure as Tank Base)

then the Tank node has no collision mesh set and thus falls through the floor.

Is there a way to tell Tank To use the collision shapes of its children?

At the moment it seems like there is no way of doing this.

Children Colliding with Parents

When I tried to instead make this non-modular (allthough I realy want the modularity of having different parts be their own scenes ) and used the same structure as above with the addition of a CollisionShape3D node in Tank, then it suddenly started to fly or fall through the floor.

The reason for this, as i found out is that the Tank collision mesh is colliding with it’s identical counterpart in TankBase.
After setting this to a different collision layer, everything worked. But this tells me that there must be some way for Tank to find and use the collision shapes of its children as its own.

I hope this wasn’t to much of an overload.
Is the behavior i’m seeking even possible, or how would one approach this design problem in Godot?

Thanks for the Help!

Instead of the modules being staticbodies why dont you make them collisionshapes?

Thanks! That’s a good idea. It almost solves my problem, when setup correctly.
( Just as a reference how I did it now)

  1. Import the mesh from blender as CollisionShape3D giving the structure
TankBase(CollisionShape3D)
- TankBaseMesh(MeshInstance3D)
  1. Create the collision shape from TankBaseMesh.
  2. Save the collision shape.
  3. Set the saved shape as the shape of TankBase
  4. Remove the previously generated CollisionShape3D

There are three problems that arrise for me now:

  1. Each part of the character now has to be a direct child of the Tank node, otherwise it does not create collisions while navigating with move_and_slide.
    For a tank this isn’t tooo much of an issue, but if you think of an arm of a robot, it would be rather annoying not to have the hand parented to the arm parented to the torso. Or even just a second tower on the tank . I would manually have to propagate all transformations via code, which seems like it should rather be done with parenting of nodes.

  2. When making my own collision meshes in Blender with the -colonly suffix, I cannot tell the root node to use the collisions of the children (in this case the manually generated collision mesh). This means that I would have to do the saving and deleting steps from above, both of which do not work, as the scene inherits from the import and cannot delete parts and directly save meshes.

  3. The Root node complains, that it is not parented to a StaticBody3D or similar. This shouldn’t be a problem as the whole scene later gets parented to a compatible node type.