bovido/scripts/player/states/player_idle_state.gd

24 lines
572 B
GDScript

class_name PlayerIdleState
extends PlayerState
var collide_with_ball = false
func enter(_msg := {}):
player.velocity = Vector2.ZERO
player.animation_player.play("idle")
func update(_delta):
if collide_with_ball && Input.is_action_pressed("hit"):
collide_with_ball = false
state_machine.transition_to("Throw")
if get_input_direction() != Vector2.ZERO:
state_machine.transition_to("Walk")
func get_input_direction():
return Input.get_vector("move_left", "move_right", "move_up", "move_down")
func _on_player_collide_with_ball():
collide_with_ball = true