Skip to main content
Bumped by Community user
No need to invent your own tagging syntax — question tags already work this way.
Link
DMGregory
  • 136.3k
  • 22
  • 247
  • 373

Godot - Detect collisions with both parent and child nodes in Godot

Source Link

Godot - Detect collisions with both parent and child nodes

Using Godot 4.2.1, 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 it to a StaticBody3D too, but the issue persists. The collision layers and masks are the same for both parent and child; if that was wrong, the collision wouldn't work for either.

How can I get the child's collision to be detected? And the movement to stop 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?