Area3D detects "body_exited" immediately after "body_entered"

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By GreenT34

Using print statements, I have determined that whenever the Player (kinematicBody) enters an Area, both the signal “body_entered” and “body_exited” trigger at the same time, consecutively.
It is as if the player exits the area as soon as it enters it, but that can’t be possible.

I have checked:
collision layers & masks,
the player movement script,
my version of godot.

I have tried:
Making the area’s collision box bigger.


I would like to know

  1. Has this happened before
  2. What your fix was
  3. What the cause was.

I am willing and able to share as much information as needed.

I had something similar, solved it by printing the name of the nodes interacting - print(body.get_name()) ended up being a node on the wrong collision layer. Also do you have a raycast on your kinematicBody? That could also trigger the Area.

Coenster | 2022-08-30 12:52

:bust_in_silhouette: Reply From: SteveSmith

It’s either a different area, or your area entered code is moving the player out of the area.

:bust_in_silhouette: Reply From: rr_baidy

Changing layer and mask worked for me.

Trick:

You can wrap your intended code in if logic.

E.g:

if (body.name == 'Enemy' || body.name.begins_with('Enemy')):
    #your code snipet