Compare commits

..

2 commits

Author SHA1 Message Date
31f1de7d68 Halve edgeSensorRange to 12 so edge wraps need the slime at the edge
Pressing into a surface now only wraps around its edge when the slime's
center is within 12px of it, i.e. the slime is touching the edge (about
1px gap), instead of up to 13px away with the old 24. Walking up to an
edge still always works, since the edge hold stops the slime there.

Measured with a headless sweep of 24/16/14/12/10/8/6/4 on floors,
ceilings and wall bottoms.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-31 15:54:34 -07:00
ad9e8d62fa Stop the edge sensors from hitting the player's own collider
Since the sensors moved under the EdgeSensors pivot, exclude_parent
excludes the pivot rather than the player. With edgeSensorRange equal to
the slime's radius the rays start on the edge of its circle and hit it,
so edge wraps never triggered. Add the player as an exception.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-31 15:54:15 -07:00
2 changed files with 7 additions and 3 deletions

View file

@ -78,7 +78,7 @@ var wrapEntryLength := 0.0
# we're on, a little way to each side of us. If one stops touching the surface, # we're on, a little way to each side of us. If one stops touching the surface,
# there's an edge within edgeSensorRange on that side, and pressing into the # there's an edge within edgeSensorRange on that side, and pressing into the
# surface will slide over it onto the side of the platform. # surface will slide over it onto the side of the platform.
@export var edgeSensorRange := 24.0 @export var edgeSensorRange := 12.0
var wallFacingY := -1.0 # Which way we last moved along a wall (-1 is up). var wallFacingY := -1.0 # Which way we last moved along a wall (-1 is up).
# Holding at an edge: moving along a surface towards its edge stops at the edge, # Holding at an edge: moving along a surface towards its edge stops at the edge,
@ -92,6 +92,10 @@ func _ready() -> void:
leftEdgeSensor.target_position = Vector2(0, sensorDepth) leftEdgeSensor.target_position = Vector2(0, sensorDepth)
rightEdgeSensor.position = Vector2(edgeSensorRange, 0) rightEdgeSensor.position = Vector2(edgeSensorRange, 0)
rightEdgeSensor.target_position = Vector2(0, sensorDepth) rightEdgeSensor.target_position = Vector2(0, sensorDepth)
# The sensors' parent is the EdgeSensors pivot, so exclude_parent doesn't
# cover us. Without this they can hit our own collider.
leftEdgeSensor.add_exception(self)
rightEdgeSensor.add_exception(self)
# Rotates the sprite to sit on the wall or ceiling. Done in _physics_process # Rotates the sprite to sit on the wall or ceiling. Done in _physics_process
# (not _process) so physics interpolation smooths it along with our movement. # (not _process) so physics interpolation smooths it along with our movement.

View file

@ -26,11 +26,11 @@ shape = SubResource("CircleShape2D_eovys")
[node name="EdgeSensors" type="Node2D" parent="."] [node name="EdgeSensors" type="Node2D" parent="."]
[node name="LeftEdgeSensor" type="RayCast2D" parent="EdgeSensors"] [node name="LeftEdgeSensor" type="RayCast2D" parent="EdgeSensors"]
position = Vector2(-24, 0) position = Vector2(-12, 0)
target_position = Vector2(0, 14) target_position = Vector2(0, 14)
[node name="RightEdgeSensor" type="RayCast2D" parent="EdgeSensors"] [node name="RightEdgeSensor" type="RayCast2D" parent="EdgeSensors"]
position = Vector2(24, 0) position = Vector2(12, 0)
target_position = Vector2(0, 14) target_position = Vector2(0, 14)
[node name="SplatParticles" type="CPUParticles2D" parent="."] [node name="SplatParticles" type="CPUParticles2D" parent="."]