bovido/scripts/player/states/player_idle_state.gd

22 lines
540 B
GDScript3
Raw Normal View History

class_name PlayerIdleState
extends PlayerState
2023-06-28 00:07:13 +02:00
var player_collide_with_ball = false
func enter(_msg := {}):
player.velocity = Vector2.ZERO
2023-06-28 21:29:55 +02:00
player.play_idle_animation()
func update(_delta):
2023-06-28 00:07:13 +02:00
if player_collide_with_ball && Input.is_action_pressed("hit"):
2023-06-28 21:29:55 +02:00
state_machine.transition_to("HitBall")
2023-06-28 00:07:13 +02:00
if player.get_input_direction() != Vector2.ZERO:
state_machine.transition_to("Walk")
2023-06-28 00:07:13 +02:00
func _on_player_ball_starts_colliding():
player_collide_with_ball = true
2023-06-28 00:07:13 +02:00
func _on_player_ball_stops_colliding():
player_collide_with_ball = false