bovido/scripts/throw_ball_action.gd
Mathilde Grapin 92ccf7279d Instanciate a ball
Make the enemy throw a ball. It just instanciate a ball in the scene but
does not move it.
2023-06-12 22:06:48 +02:00

26 lines
618 B
GDScript

class_name ThrowBallAction
extends ActionLeaf
var has_animation_finished = false
func before_run(actor, _blackboard):
actor.animation_player.animation_finished.connect(_on_animation_finished)
actor.animation_player.speed_scale = 0.8
func tick(actor, _blackboard):
actor.animation_player.play("throw")
if !has_animation_finished:
return RUNNING
else:
actor.throw_ball()
actor.has_thrown_ball = true
return SUCCESS
func after_run(actor, _blackboard):
actor.animation_player.play("idle")
actor.animation_player.speed_scale = 1
func _on_animation_finished(_anim_name):
has_animation_finished = true