22 lines
544 B
GDScript
22 lines
544 B
GDScript
class_name PlayerIdleState
|
|
extends PlayerState
|
|
|
|
var player_collide_with_ball = false
|
|
|
|
func enter(_msg := {}):
|
|
player.velocity = Vector2.ZERO
|
|
player.animation_player.play("idle")
|
|
|
|
func update(_delta):
|
|
if player_collide_with_ball && Input.is_action_pressed("hit"):
|
|
state_machine.transition_to("Hit")
|
|
|
|
if player.get_input_direction() != Vector2.ZERO:
|
|
state_machine.transition_to("Walk")
|
|
|
|
func _on_player_ball_starts_colliding():
|
|
player_collide_with_ball = true
|
|
|
|
func _on_player_ball_stops_colliding():
|
|
player_collide_with_ball = false
|