forked from team-sg/hero-mark-2
fix ladder jump bug (closes #132)
This commit is contained in:
parent
f2ff65807a
commit
311528e6ed
2 changed files with 11 additions and 4 deletions
|
@ -231,8 +231,6 @@ func _on_Climbing_state_entered() -> void:
|
||||||
var input_dir = sign(Input.get_axis("ui_left", "ui_right"))
|
var input_dir = sign(Input.get_axis("ui_left", "ui_right"))
|
||||||
var ladder_dir = sign(_attached_ladder.middle - global_position.x)
|
var ladder_dir = sign(_attached_ladder.middle - global_position.x)
|
||||||
var flip = global_position.y - 1.0 <= _attached_ladder.global_position.y and input_dir == ladder_dir and is_on_floor()
|
var flip = global_position.y - 1.0 <= _attached_ladder.global_position.y and input_dir == ladder_dir and is_on_floor()
|
||||||
print(ladder_dir)
|
|
||||||
print(flip)
|
|
||||||
if ladder_dir >= 0.0 != flip:
|
if ladder_dir >= 0.0 != flip:
|
||||||
global_position.x = _attached_ladder.left_snap
|
global_position.x = _attached_ladder.left_snap
|
||||||
graphics.scale.x = 1.0
|
graphics.scale.x = 1.0
|
||||||
|
@ -358,20 +356,24 @@ func _process_climbing(delta: float) -> void:
|
||||||
ladder_detector.force_raycast_update()
|
ladder_detector.force_raycast_update()
|
||||||
if ladder_detector.get_collider() != _attached_ladder:
|
if ladder_detector.get_collider() != _attached_ladder:
|
||||||
if input_dir == -1.0:
|
if input_dir == -1.0:
|
||||||
state_chart.send_event("ladder_jump")
|
state_chart.send_event("ladder_peak")
|
||||||
|
return
|
||||||
else:
|
else:
|
||||||
state_chart.send_event("ladder_detach")
|
state_chart.send_event("ladder_detach")
|
||||||
|
return
|
||||||
else:
|
else:
|
||||||
if Input.is_action_just_pressed("jump"):
|
if Input.is_action_just_pressed("jump"):
|
||||||
var horizontal_dir = sign(Input.get_axis("ui_left", "ui_right"))
|
var horizontal_dir = sign(Input.get_axis("ui_left", "ui_right"))
|
||||||
if sign(_attached_ladder.middle - global_position.x) != horizontal_dir:
|
if sign(_attached_ladder.middle - global_position.x) != horizontal_dir:
|
||||||
global_position.x -= graphics.scale.x * 3.0
|
global_position.x -= graphics.scale.x * 3.0
|
||||||
state_chart.send_event("ladder_jump")
|
state_chart.send_event("ladder_jump")
|
||||||
|
return
|
||||||
elif Input.is_action_just_pressed("shoot"):
|
elif Input.is_action_just_pressed("shoot"):
|
||||||
var horizontal_dir = sign(Input.get_axis("ui_left", "ui_right"))
|
var horizontal_dir = sign(Input.get_axis("ui_left", "ui_right"))
|
||||||
if sign(_attached_ladder.middle - global_position.x) != horizontal_dir:
|
if sign(_attached_ladder.middle - global_position.x) != horizontal_dir:
|
||||||
global_position.x -= graphics.scale.x * 3.0
|
global_position.x -= graphics.scale.x * 3.0
|
||||||
state_chart.send_event("ladder_detach")
|
state_chart.send_event("ladder_detach")
|
||||||
|
return
|
||||||
# # auto-dismount on ground
|
# # auto-dismount on ground
|
||||||
# elif Input.is_action_pressed("ui_down") and is_on_floor():
|
# elif Input.is_action_pressed("ui_down") and is_on_floor():
|
||||||
# var horizontal_dir = sign(Input.get_axis("ui_left", "ui_right"))
|
# var horizontal_dir = sign(Input.get_axis("ui_left", "ui_right"))
|
||||||
|
|
|
@ -1408,9 +1408,14 @@ __meta__ = {
|
||||||
"_editor_description_": "stuck to ladder"
|
"_editor_description_": "stuck to ladder"
|
||||||
}
|
}
|
||||||
|
|
||||||
[node name="On LadderJump" type="Node" parent="StateChart/Root/Movement/Climbing"]
|
[node name="On LadderPeak" type="Node" parent="StateChart/Root/Movement/Climbing"]
|
||||||
script = ExtResource( 10 )
|
script = ExtResource( 10 )
|
||||||
to = NodePath("../../Airborne/Jump/LadderJump")
|
to = NodePath("../../Airborne/Jump/LadderJump")
|
||||||
|
event = "ladder_peak"
|
||||||
|
|
||||||
|
[node name="On LadderJump" type="Node" parent="StateChart/Root/Movement/Climbing"]
|
||||||
|
script = ExtResource( 10 )
|
||||||
|
to = NodePath("../../Airborne/Jump/NormalJump")
|
||||||
event = "ladder_jump"
|
event = "ladder_jump"
|
||||||
|
|
||||||
[node name="On LadderDetach" type="Node" parent="StateChart/Root/Movement/Climbing"]
|
[node name="On LadderDetach" type="Node" parent="StateChart/Root/Movement/Climbing"]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue