|
|
|
|
@ -39,6 +39,9 @@ func on_enter_idle_state(): |
|
|
|
|
func idle_state(_delta): |
|
|
|
|
var direction = Input.get_axis("ui_left", "ui_right") |
|
|
|
|
|
|
|
|
|
if is_on_floor(): |
|
|
|
|
velocity.x = 0 |
|
|
|
|
|
|
|
|
|
if direction: |
|
|
|
|
$fsm.set_next_state("walk") |
|
|
|
|
elif Input.is_action_just_pressed("ui_accept") and is_on_floor(): |
|
|
|
|
@ -57,7 +60,7 @@ func walk_state(_delta): |
|
|
|
|
$fsm.set_next_state("jump") |
|
|
|
|
|
|
|
|
|
# detect collision with wall or ceiling to enter climb state |
|
|
|
|
if is_on_wall() or is_on_ceiling(): |
|
|
|
|
if is_on_wall() or (Input.is_action_pressed('ui_up') && is_on_ceiling()): |
|
|
|
|
velocity.y = 0 |
|
|
|
|
$fsm.set_next_state("climb") |
|
|
|
|
|
|
|
|
|
@ -78,7 +81,7 @@ func jump_state(_delta): |
|
|
|
|
velocity.x = 0 |
|
|
|
|
$fsm.set_next_state("idle") |
|
|
|
|
|
|
|
|
|
if is_on_wall() or is_on_ceiling(): |
|
|
|
|
if is_on_wall() || (is_on_ceiling() and Input.is_action_pressed("ui_up")): |
|
|
|
|
$fsm.set_next_state("climb") |
|
|
|
|
|
|
|
|
|
func on_enter_climb_state(): |
|
|
|
|
|