bovido/scripts/enemy/behavior_tree/throw_ball_action.gd

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