forked from team-sg/hero-mark-2
disallow jumping while pressing towards ladder
This commit is contained in:
parent
6946592a6e
commit
39d7387f61
2 changed files with 13 additions and 10 deletions
|
@ -280,19 +280,21 @@ func _process_climbing(delta: float) -> void:
|
||||||
# global_position.x = _attached_ladder.left_snap
|
# global_position.x = _attached_ladder.left_snap
|
||||||
# graphics.scale.x = 1.0
|
# graphics.scale.x = 1.0
|
||||||
|
|
||||||
if Input.is_action_just_pressed("jump"):
|
|
||||||
global_position.x -= graphics.scale.x * 3.0
|
|
||||||
state_chart.send_event("jump")
|
|
||||||
if Input.is_action_just_pressed("shoot"):
|
|
||||||
global_position.x -= graphics.scale.x * 3.0
|
|
||||||
state_chart.send_event("ladder_detach")
|
|
||||||
|
|
||||||
# check if still on ladder
|
# check if still on ladder
|
||||||
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("jump")
|
state_chart.send_event("ladder_jump")
|
||||||
else:
|
else:
|
||||||
state_chart.send_event("ladder_detach")
|
state_chart.send_event("ladder_detach")
|
||||||
|
else:
|
||||||
|
if Input.is_action_just_pressed("jump"):
|
||||||
|
var horizontal_dir = sign(Input.get_axis("ui_left", "ui_right"))
|
||||||
|
if sign(_attached_ladder.middle - global_position.x) != horizontal_dir:
|
||||||
|
global_position.x -= graphics.scale.x * 3.0
|
||||||
|
state_chart.send_event("ladder_jump")
|
||||||
|
if Input.is_action_just_pressed("shoot"):
|
||||||
|
global_position.x -= graphics.scale.x * 3.0
|
||||||
|
state_chart.send_event("ladder_detach")
|
||||||
|
|
||||||
func _process_jump(delta: float) -> void:
|
func _process_jump(delta: float) -> void:
|
||||||
if velocity.y >= 0.0:
|
if velocity.y >= 0.0:
|
||||||
|
|
|
@ -1087,10 +1087,10 @@ __meta__ = {
|
||||||
"_editor_description_": "stuck to ladder"
|
"_editor_description_": "stuck to ladder"
|
||||||
}
|
}
|
||||||
|
|
||||||
[node name="On Jump" type="Node" parent="StateChart/Root/Movement/Climbing"]
|
[node name="On LadderJump" type="Node" parent="StateChart/Root/Movement/Climbing"]
|
||||||
script = ExtResource( 10 )
|
script = ExtResource( 10 )
|
||||||
to = NodePath("../../Airborne/Jump/LadderJump")
|
to = NodePath("../../Airborne/Jump/LadderJump")
|
||||||
event = "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"]
|
||||||
script = ExtResource( 10 )
|
script = ExtResource( 10 )
|
||||||
|
@ -1143,6 +1143,7 @@ guard_expression = "can_respawn"
|
||||||
layer = 128
|
layer = 128
|
||||||
|
|
||||||
[node name="StateChartDebug" type="Tree" parent="StateDebugLayer"]
|
[node name="StateChartDebug" type="Tree" parent="StateDebugLayer"]
|
||||||
|
visible = false
|
||||||
anchor_left = 1.0
|
anchor_left = 1.0
|
||||||
anchor_right = 1.0
|
anchor_right = 1.0
|
||||||
margin_left = -147.0
|
margin_left = -147.0
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue