Area2D does not detect the other body.
Godot version
v3.6.beta1.official [632a544c6]
System information
w10 64
Issue description
Problem: The area2D of the "Player" node does not detect the body of the enemy.
To fix it make the collisionshape assigned to the area2D even bigger (currently it is 17x17) but this is not fixed, I mean you will have to make the area bigger even if the movement speeds of the nodes change.
I mean, the size of the area will be tied to the movement speeds of the nodes somehow.
So how is this understood? What size should I put in the area if it can become too big? I cannot be assigning different sizes to the area2D depending on the speed of the nodes.
Steps to reproduce
Just play the project and you'll see that when the "Enemy" node reaches the "Player" node then you don't get the body name written to the output.
Minimal reproduction project
Here's a close-up of what happens:
https://user-images.githubusercontent.com/2223172/232910087-df080e40-c0cc-4f6b-836b-a25308d2fa44.mp4
The left sprite is moving faster, so once it collides with the right one, they stick together from now on. But for whatever reason get_overlapping_bodies() in the area is empty. Changing to lower time_scale fixes the issue, so it has something to do with area not detecting the body in time.
Changing time_scale in my project is not a solution, I have to use a time_scale = 0.4 for detection to occur. I hope someone please fix this soon...
Fixes happen based on availability of contributors and detection of the cause
I am aware of that, which is why I say that I "hope".
I think it is related with: https://github.com/godotengine/godot/issues/43743
I think it is related with: #43743
I'm not sure if they are related. In the other project: https://github.com/godotengine/godot/issues/43743 it is not detected perhaps because of the high speed.
In this one the speed is low, it even collides with the other body and the area is being invaded in each frame but still, the detection is not registered.
This won't be fixed in 3.7? I mean that it doesn't have a milestone assigned.
In the version of Godot v4.5.dev1.official [97241ffea], this error is fixed if we deactivate mask 1 for the enemy, but I don't see the point.
In version v3.7.dev.custom_build [5155fe5a4], that solution does not apply and the error continues to occur.
Still in v4.5.beta1.official [46c495ca2]
Still in v3.6.1.stable.official [b1ba98fce]
In 4.6 dev2, detection occurs… but it behaves strangely. Initially, it doesn’t detect even though the bodies are already being touched; after about 2 seconds, it detects and prints "Enemy" to the output.
Therefore, I would say that the problem persists in 4.6 dev2.
Change size of Area2D from 34.0 to 34.01 can make colliding immediately.
The step as follows:
- player
move_and_slide, original x=100, new x=100.5 - enemy
move_and_slide, original x=67.5, new x=68 - The distance from enemy to player is
32.5, motion is0.5, margin is0.08 - First, update StaticBody2D,
Area2Dx=100.5 - Second, check whether enemy (x=67.5) checked with area(100.5).
- The distance between enemy to area is
33, equals half of enemy width(16) plus half of area width(17). Because of precision, add a 0.01 can make colliding consistent.