forked from Julian/JuegoClase
28 lines
692 B
GDScript
28 lines
692 B
GDScript
extends PlayerState
|
|
|
|
func state_enter_state(msg := {}):
|
|
anim_player.play("walk")
|
|
|
|
func state_physics_process(delta):
|
|
var direccion = Input.get_axis("ui_left","ui_right")
|
|
player.sprite.flip_h = direccion < 0 if direccion != 0 else player.sprite.flip_h
|
|
|
|
|
|
player.velocity.x = direccion * player.speed
|
|
|
|
|
|
player.move_and_slide()
|
|
|
|
|
|
#print(direccion)
|
|
if direccion == 0:
|
|
state_machine.transition_to("Idle")
|
|
elif !player.is_on_floor():
|
|
state_machine.transition_to("enAire")
|
|
elif Input.is_action_just_pressed("ui_accept"):
|
|
state_machine.transition_to("enAire",{Salto = true})
|
|
elif Input.is_action_just_pressed("dash") and player.canDash:
|
|
state_machine.transition_to("Dash")
|
|
|
|
|