Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Raycast2d does not collide with CircleShape2d in CollisionShape2d, but does work with RectangleShape2d. #39859

Closed
Tracked by #39876 ...
ahayzen opened this issue Jun 26, 2020 · 2 comments · Fixed by #54857

Comments

@ahayzen
Copy link

ahayzen commented Jun 26, 2020

Godot version:

v3.2.2.stable.mono.official

OS/device including version:

Debian 10, Intel Corporation HD Graphics 620, GLES2.
Windows 7 Professional Service Pack 1, Intel, GLES2.

Issue description:
Raycast2d does not collide with CircleShape2d in CollisionShape2d (and potentially others), but does work with RectangleShape2d.

Steps to reproduce:

  • Create an Area2d with a CollisionShape2d using a CircleShape2d
  • Add a Raycast2d that is positioned inside the collision shape
  • Ensure the raycast2d is set to collide with areas and enabled
  • Call get_collider() on the raycast2d and observe that null is returned.

Notice that if a RectangleShape2d is used, then the raycast2d correctly reports the collider as the area2d.

Minimal reproduction project:

raycast_circular_collision_bug.zip

When running the minimal project, observe the following output in the console, showing that the raycast2d on the circleshape2d thinks it is not colliding whereas the raycast2d on the rectangle is.

Circle Raycast Collider: [Object:null]
Rect Raycast Collider: [Area2D:1188]
@Xrayez
Copy link
Contributor

Xrayez commented Jun 27, 2020

I confirm this. Though I'm not sure if you're supposed to have a raycast length of 0, in either case it doesn't work if casting happens from inside of some shapes, see related issues at #39876. If you set a cast_to = Vector2(10, 0) and move the origin outside the circle shape, it detects the area.

@aphilip442
Copy link

Had the same issue.

It works with raycast origin (and destination) within an Area2D for a RectangleShape2D, but is only updated when raycast is entering the shape if CircleShape2D is used instead.

This is inconsistent, bugged, behavior.

(Using version 3.3.2)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment