bovido/scripts/player/states/player_walk_state.gd

19 lines
469 B
GDScript3
Raw Normal View History

class_name PlayerWalkState
extends PlayerState
func enter(_msg := {}):
player.animation_player.play("walk")
func physics_update(delta):
2023-06-28 00:07:13 +02:00
var direction = player.get_input_direction()
var velocity = direction * player.speed
2023-06-28 00:07:13 +02:00
player.flip_sprite()
var collision = player.move_and_collide(velocity * delta)
if collision and Input.is_action_pressed("hit"):
2023-06-28 00:07:13 +02:00
state_machine.transition_to("Hit")
if velocity == Vector2.ZERO:
state_machine.transition_to("Idle")