bovido/scripts/enemy/behavior_tree/throw_ball_action.gd

27 lines
666 B
GDScript

class_name ThrowBallAction
extends ActionLeaf
var is_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 !is_animation_finished:
return RUNNING
else:
var target = blackboard.get_value("target")
actor.throw_ball(target)
actor.has_thrown_ball = true
return SUCCESS
func after_run(actor, _blackboard):
actor.animation_player.speed_scale = 1
actor.animation_player.play("idle")
func _on_animation_finished(_anim_name):
is_animation_finished = true