bovido/scripts/player/states/player_walk_state.gd

19 lines
464 B
GDScript3
Raw Normal View History

class_name PlayerWalkState
extends PlayerState
func enter(_msg := {}):
2023-06-28 21:29:55 +02:00
player.play_walk_animation()
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()
2023-06-28 21:29:55 +02:00
var collision = player.move_and_collide(velocity * delta)
if collision and Input.is_action_pressed("hit"):
2023-06-28 21:29:55 +02:00
state_machine.transition_to("HitBall")
if velocity == Vector2.ZERO:
state_machine.transition_to("Idle")