Hop across to a surface within a tile (floor, walls and ceilings) #5
1 changed files with 11 additions and 0 deletions
|
|
@ -530,7 +530,18 @@ func _update_wrap(delta: float) -> void:
|
|||
# Done with move_and_slide so is_on_floor()/is_on_wall() are up to date
|
||||
# instead of still describing where we were before the wrap.
|
||||
velocity = -wrapOntoNormal * (WRAP_MARGIN + 1) / delta
|
||||
# Godot still thinks we're on whatever floor we were on before the wrap, so
|
||||
# it would try to snap us down onto it, and (floor_block_on_wall) count the
|
||||
# wall we're pushing into as floor. Only allow that if we're ending on a floor.
|
||||
var endingOnFloor := wrapOntoNormal == Vector2.UP
|
||||
var floorSnap := floor_snap_length
|
||||
var blockOnWall := floor_block_on_wall
|
||||
if not endingOnFloor:
|
||||
floor_snap_length = 0.0
|
||||
floor_block_on_wall = false
|
||||
move_and_slide()
|
||||
floor_snap_length = floorSnap
|
||||
floor_block_on_wall = blockOnWall
|
||||
# Carry on at the same speed along the new surface, so leaving the wrap
|
||||
# isn't a sudden stop. Normal movement then speeds up or slows down from here.
|
||||
var exitDirection := wrapExitOffset.normalized() if wrapExitOffset != Vector2.ZERO \
|
||||
|
|
|
|||
Loading…
Reference in a new issue