appsinacup / godot-box2d

Godot Box2D – C++ Godot Extension that integrates the Box2D physics engine.
MIT License
329 stars 15 forks source link

CapsuleShape2D causing weird Interaction with intersect_ray and StaticBody2D #106

Open markweenwork opened 8 months ago

markweenwork commented 8 months ago

CapsuleShape2D collision shape (when height to radius ratio is above 2:1) is some how affecting intersect_ray (that intersects 2 non overlapping StaticBody2D objects) queries on 2 StaticBody2Ds - When the Capsule collides with one of the StaticBody2D objects the intersect_ray seems to ignore one of the StaticBody2D objects even though the ray hits it and it is the closer intersection

sample scene provoided

TO REPRODUCE

  1. open sample scene
  2. play the scene
  3. there is a script on the root node that casts an instersect_ray (represented as a green line) through two non overlapping StaticBody2D objects - it turns the color of the object it hits to red (both objects are reset to white in the _physics_process func)
  4. a RigidBody2D object with a CapsuleShape2D (with height to radius ratio of above 2:1) drops and lands on one of the StaticBody2D objects - this seems to affect the intersect_ray as it changes which object the intersect_ray now collides with
  5. if you change RigidBody2D->CollisionShape2D->Shape->Height to 40.0px this bug no longer happens

EXPECTED BEHAVIOUR

Unless I am doing something wrong or missing something - the interaction between the CapsuleShape2D and the StaticBody2D should in this case not have any effect on the intersect_ray result

VERSIONS

RayIntersectBugBox2D.zip

Capsule2Dbug