Don't treat tile seams or the foot of a wall as an edge
The level's TileMapLayer is made of separate collision shapes, and the ray that looks for the side of a platform could hit the inside face of a neighbouring tile. That made walking along the floor stop and "hold" at tile seams and next to walls. A corner now only counts as an edge if there's empty space just past it, behind the surface. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
e5c176f1f6
commit
c212748b8d
1 changed files with 5 additions and 1 deletions
|
|
@ -383,7 +383,11 @@ func _find_edge_corner(normal: Vector2, dir: Vector2, reach: float) -> Variant:
|
||||||
var line: Vector2 = surfaceHit.position - normal * 2 + dir * (pos - surfaceHit.position).dot(dir)
|
var line: Vector2 = surfaceHit.position - normal * 2 + dir * (pos - surfaceHit.position).dot(dir)
|
||||||
var faceHit := _cast_ray(line + dir * reach, line - dir * radius)
|
var faceHit := _cast_ray(line + dir * reach, line - dir * radius)
|
||||||
if not faceHit or faceHit.normal.dot(dir) < 0.5: return null
|
if not faceHit or faceHit.normal.dot(dir) < 0.5: return null
|
||||||
return faceHit.position + normal * 2
|
var corner: Vector2 = faceHit.position + normal * 2
|
||||||
|
# A real edge has empty space just past it, behind the surface. Seams
|
||||||
|
# between tiles (and the foot of a wall) have solid there, so they're not edges.
|
||||||
|
if not _is_point_free(corner + dir * 2 - normal * 2): return null
|
||||||
|
return corner
|
||||||
|
|
||||||
# If this frame's movement along the surface would take us past its edge, stop
|
# If this frame's movement along the surface would take us past its edge, stop
|
||||||
# at the edge instead, until we've held towards it for MAX_SECS_TO_UNSTICK.
|
# at the edge instead, until we've held towards it for MAX_SECS_TO_UNSTICK.
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue