move_and_collide causes _on_body_entered to fail. How do I work around?

Godot Version

4.2.2

Question

My current project has a Volleyball object/scene and a Hitter object/scene. The Hitter object is an Area3D node that works by having a _on_body_entered function to detect when a ball enters its hitbox. The ball is for the most part a is a RigidBody3D with a class_name. I’m trying to make the ball bounce when it collides and so I added some script and the Hitter’s _on_body_entered is not activating (there is a print function that is called on the first line of the function that is not being called nor is the reset of the code seeming to work). After some fiddling around I have determined that if the ball calls move_and_collide in its _physics_process then it seems to stop _on_body_entered from being called when the ball enters the hit box.

Ideally I want to understand why move_and_collide causes _on_body_entered to fail or what third factor I am not considering that might be causing the failure, but I would appreciate any suggestions for work arounds as well.

If you need any more information I’ll try to provide it and apologies if this post is obvious or poorly formatted as I am new to Godot and this forum.

Information that I think is irrelevant but could be for determining a work around or I could just be wrong about,

  • the ball is on layers 1 and 2 with a mask on 1, and the hitter is on 2 with a mask on 2.
  • the hitter does the detection because it attempts to hit the ball at a target node it has

I think move_and_collide() doesn’t enter the body because it stops the body when it collides. What you can do instead is use the return value from move_and_collide(), it’s a KinematicCollision3D that tells you all about the collision, if there was one.

Also, you may need to use something other than Area3D for the hitter, something that inherits from PhysicsBody3D.