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

Raycasts inside Tilemaps only collide at the edge. #44003

Closed
Tracked by #39876 ...
RPicster opened this issue Dec 1, 2020 · 1 comment · Fixed by #54857
Closed
Tracked by #39876 ...

Raycasts inside Tilemaps only collide at the edge. #44003

RPicster opened this issue Dec 1, 2020 · 1 comment · Fixed by #54857

Comments

@RPicster
Copy link
Contributor

RPicster commented Dec 1, 2020

Godot version:
3.2.3 stable

OS/device including version:
GLES3
Windows 10 Pro - 10.0.19042
Nvidia RTX 2080

Issue description:
When using a Raycast (of any kind, as a RayCast2D node or as a direct_space_state intersect_ray) to detect collision on a Tilemap, the collision is only detected at the edge of the Tilemap.

On other bodies, eg. a StaticBody, the Raycast is immediately stopped when it is inside the body. Not so on a Tilemap.
When casted inside a Tilemap, the Raycast will have no collision result unless it hits a wall edge.

image

Steps to reproduce:

  • Create a TileMap node with a Tileset that has collision
  • Create a RayCast2D node and place it inside the TileMap
  • Setup the collision masks accordingly

Minimal reproduction project:
tilemap_collision_raycast_bug.zip

@creikey
Copy link
Contributor

creikey commented Dec 8, 2020

This is an issue with ConvexPolygonShape2DSW::intersect_segment in shape_2d_sw.cpp:

if (!Geometry::segment_intersects_segment_2d(p_begin, p_end, points[i].pos, points[(i + 1) % point_count].pos, &res))
			continue;

This is in a loop where it's iterating over all the points in the polygon it seems. To fix this maybe an initial check to see if the starting point is inside the convex polygon?

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