The body_enter signal is not emitted if the body passes through an Area2D finishes move behind the Area2D

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By lukas
:warning: Old Version Published before Godot 3 was released.

When I move KinematicBody2D with move(), Area2D emits body_enter signal only if the collision shapes of these bodies overlap at the end of the move. If the kinematic body passes through the area and finishes behind the area, the signal is not emitted.

Is that expected and wanted behaviour or is it a bug? I would expect that the signal is emitted every time the kinematic body passes through the area.

I’m not familiar with physics, but there is an option for physics at Project Settings > Physics > fixed fps
try to increase this fixed fps value, like 120.

volzhs | 2017-05-20 14:28

I think that it is not a physics problem because if I change Area2D to StaticBody2D and make the same move, the KinematicBody2D stops as expected.

lukas | 2017-05-20 14:32

This isn’t a bug, but an unrealistic expectation of the Area2D. I believe your KinematicBody2D is moving pretty fast in relation to the size of your Area2D. The Area2D really should be something where a body enters it on frame X and will be there for several frames afterwards. I don’t know the internals of the Physics Engine, but the PhysicsBody2D’s are much more optimized to handle these types of collisions(short) you described. You most likely need to increase the size of your Area2D.

2D||!2D | 2017-05-21 14:00

I understand that. And this is also my amateurish explanation to it. But I definitively have no idea how the physics bodies and areas are implemented in Godot. That is why I asked. So probably it is an expected behaviour.
(From my naive point of view I was expecting that Area2D is able to detect exactly the same collisions as other physic bodies.)

lukas | 2017-05-21 14:36

:bust_in_silhouette: Reply From: eons

Objects in games do not use a real movement, they moves the programmed amount.

When using overlap detection (case of areas here or non solid/trigger on other engines) if the bodies minimum motion is greater than the area, they will jump over it and the overlap will never occur.

Is not the same between PhysicBodies, rigid and kinematic (using move) will try to avoid tunnelling against “solid” objects.


So, your problem is the design, the area is too small to see a body at high speed.

To fix this, reducing the problematic speed is not an option, usually.
You can try:

  • Increase the area size according to the speed (not common but sometimes is possible).
  • Add a raycast that grows with speed, use it in the moving body to predict overlaps.
  • Change the detection zone, you can use Line shapes instead, these are currently buggy on bodies (as solids) but work fine with Area2D.