Godot-docs: AREA2D: get_overlapping_bodies() only sees KinematicBody2Ds

Created on 30 Aug 2020  路  2Comments  路  Source: godotengine/godot-docs

Godot version:
tested to happen in 3.2.2 stable and in 3.2.3 rc4

OS/device including version:
Windows 10 Build 18362
Nvidia GT650M

Issue description:
Area 2d's get_overlapping_bodies sees only kinematicbodie2Ds and not rigidbody2Ds or Staticbody2Ds

Minimal reproduction project:
Collision.zip

bug class reference

Most helpful comment

The behavior is correct, but likely needs better documentation.

Here's a fixed project that properly reports overlap for all three bodies:
Collision.zip

You were moving all three types of bodies with position.x += 1, but:

  • StaticBody2D is static, so it doesn't report collision when moving like a KinematicBody2D (setting its position directly inside the Area2D seems to work). I didn't dig further to understand exactly what the difference is, it might be covered in StaticBody2D docs, if not, that should be fixed.
  • RigidBody2D is a rigid body, and only reports collisions if used as a rigid body. If you teleport it like a KinematicBody2D by changing its position, it won't run its collision logic. Instead, if you set its linear velocity and let the physics engine move it, it will report collision/overlap just fine.

All 2 comments

The behavior is correct, but likely needs better documentation.

Here's a fixed project that properly reports overlap for all three bodies:
Collision.zip

You were moving all three types of bodies with position.x += 1, but:

  • StaticBody2D is static, so it doesn't report collision when moving like a KinematicBody2D (setting its position directly inside the Area2D seems to work). I didn't dig further to understand exactly what the difference is, it might be covered in StaticBody2D docs, if not, that should be fixed.
  • RigidBody2D is a rigid body, and only reports collisions if used as a rigid body. If you teleport it like a KinematicBody2D by changing its position, it won't run its collision logic. Instead, if you set its linear velocity and let the physics engine move it, it will report collision/overlap just fine.

Static bodies are not intended to move, so when they're moved like done in the given project, their collisions do not get updated, and that's why collision isn't detected. That's what I think.

Was this page helpful?
0 / 5 - 0 ratings