Detect collisions with both parent and child nodes

Godot Version



I have a 3D scene with a CharacterBody3D as the root. It has two children; a child CollisionShape3D, and a child CharacterBody3D with its own collision shape.

CharacterBody3D (scene root)
    CollisionShape3D (parent collision shape)
    CharacterBody3D (child)
        CollisionShape3D (child collision shape)

The scene root has a script which calls MoveAndSlide in PhysicsProcess(). It works fine for the parent and its collision shape, if you hit an obstacle, the parent stops moving. However I would like the parent to stop moving also if the child shape hits an obstacle, and that is not happening.

The child is not being moved manually through scripts, it’s only being taken along with the parent’s movement. I tried changing the child node to a StaticBody3D, but the issue persists. I tried setting the collision layers and masks to be the same for both parent and child and still only the parent collision works.

How can I get the child’s collision to be detected? And the movement to stop/slide even when the child collides, same as the parent? Is there a solution that handles this issue even when the child is instantiated at runtime, through scripts?

Why do you have a child CharacterBody3D? You can have multiple CollisionShape3D nodes as children of the same CollisionObject3D.

Eventually the child will contain more than just a collision shape. I simplified it to this when I noticed the issue to try and debug with less variables.

Other reasons to keep it separate (not necessarily part of the question) are that I would like different objects to take the place of the child during the game (hence the question about instantiation at runtime), and if possible I might want the child to have different collision layers/masks than the parent in some cases.

Have you been able to solve that problem? I am having the same issue.

The collision shapes are in the child nodes. They have to move accordingly to the movement of the bones, hence the nested structure. But they simply don’t collide. All are in Layer 1 and Mask 1.