bovido/scripts/enemy/behavior_tree/move_to_destination_action.gd

23 lines
601 B
GDScript

class_name MoveToDestinationAction
extends ActionLeaf
func before_run(actor, blackboard):
var destination = blackboard.get_value("destination")
actor.flip_sprite(destination)
actor.play_walk_animation()
func tick(actor: Node, blackboard: Blackboard):
var destination = blackboard.get_value("destination")
actor.move_to(destination)
if actor.position == destination:
actor.next_destination = null
return SUCCESS
return RUNNING
func after_run(actor, blackboard):
actor.play_idle_animation()
# Debug
var destination = blackboard.get_value("destination")
actor.reset_tile(destination)