godot icon indicating copy to clipboard operation
godot copied to clipboard

Area2D does not detect the other body.

Open Torguen opened this issue 2 years ago • 6 comments

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

testCuerposKinematic.zip

Torguen avatar Apr 18 '23 20:04 Torguen

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.

KoBeWi avatar Apr 18 '23 21:04 KoBeWi

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...

Torguen avatar Apr 19 '23 07:04 Torguen

Fixes happen based on availability of contributors and detection of the cause

AThousandShips avatar Apr 19 '23 07:04 AThousandShips

I am aware of that, which is why I say that I "hope".

Torguen avatar Apr 19 '23 07:04 Torguen

I think it is related with: https://github.com/godotengine/godot/issues/43743

AttackButton avatar Apr 25 '23 18:04 AttackButton

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.

Torguen avatar Sep 23 '24 09:09 Torguen

This won't be fixed in 3.7? I mean that it doesn't have a milestone assigned.

Torguen avatar Apr 04 '25 17:04 Torguen

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.

Torguen avatar Apr 06 '25 09:04 Torguen

Still in v4.5.beta1.official [46c495ca2]

Still in v3.6.1.stable.official [b1ba98fce]

Torguen avatar Jun 30 '25 07:06 Torguen

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.

Torguen avatar Oct 25 '25 07:10 Torguen

Change size of Area2D from 34.0 to 34.01 can make colliding immediately.

The step as follows:

  1. player move_and_slide, original x=100, new x=100.5
  2. enemy move_and_slide, original x=67.5, new x=68
  3. The distance from enemy to player is 32.5, motion is 0.5, margin is 0.08
  4. First, update StaticBody2D, Area2D x=100.5
  5. Second, check whether enemy (x=67.5) checked with area(100.5).
  6. 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.

xuhuisheng avatar Oct 31 '25 14:10 xuhuisheng