forked from team-sg/hero-mark-2
allow climbing smoothly across ladder boundaries (closes #216)
This commit is contained in:
parent
b925b22333
commit
0bc9d18762
1 changed files with 10 additions and 8 deletions
|
@ -428,14 +428,9 @@ func _process_climbing(delta: float) -> void:
|
||||||
|
|
||||||
# check if still on ladder
|
# check if still on ladder
|
||||||
ladder_detector.force_raycast_update()
|
ladder_detector.force_raycast_update()
|
||||||
if ladder_detector.get_collider() != _attached_ladder:
|
var collider = ladder_detector.get_collider()
|
||||||
if input_dir == -1.0:
|
if collider and collider.is_in_group("ladder"):
|
||||||
state_chart.send_event("ladder_peak")
|
_attached_ladder = collider
|
||||||
return
|
|
||||||
else:
|
|
||||||
state_chart.send_event("ladder_detach")
|
|
||||||
return
|
|
||||||
else:
|
|
||||||
if Input.is_action_just_pressed("jump"):
|
if Input.is_action_just_pressed("jump"):
|
||||||
var horizontal_dir = sign(Input.get_axis("move_left", "move_right") + get_stick_input(JOY_AXIS_0)) # sign() to normalize
|
var horizontal_dir = sign(Input.get_axis("move_left", "move_right") + get_stick_input(JOY_AXIS_0)) # sign() to normalize
|
||||||
if sign(_attached_ladder.middle - global_position.x) != horizontal_dir:
|
if sign(_attached_ladder.middle - global_position.x) != horizontal_dir:
|
||||||
|
@ -468,6 +463,13 @@ func _process_climbing(delta: float) -> void:
|
||||||
else:
|
else:
|
||||||
global_position.x = _attached_ladder.right_snap
|
global_position.x = _attached_ladder.right_snap
|
||||||
graphics.scale.x = -1.0
|
graphics.scale.x = -1.0
|
||||||
|
else:
|
||||||
|
if input_dir == -1.0:
|
||||||
|
state_chart.send_event("ladder_peak")
|
||||||
|
return
|
||||||
|
else:
|
||||||
|
state_chart.send_event("ladder_detach")
|
||||||
|
return
|
||||||
|
|
||||||
func _process_jump(delta: float) -> void:
|
func _process_jump(delta: float) -> void:
|
||||||
if velocity.y >= 0.0:
|
if velocity.y >= 0.0:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue