bovido/scripts/enemy/behavior_tree/move_to_destination_action.gd

17 lines
538 B
GDScript3
Raw Normal View History

2023-06-13 21:36:01 +02:00
class_name MoveToDestinationAction
extends ActionLeaf
func before_run(actor, blackboard):
var destination = blackboard.get_value("destination")
actor.sprite.flip_h = actor.position.x > destination.x
actor.animation_player.play("walk")
func tick(actor: Node, blackboard: Blackboard):
var destination = blackboard.get_value("destination")
var delta = get_physics_process_delta_time()
actor.position = actor.position.move_toward(destination, delta * actor.speed)
if actor.position == destination:
return SUCCESS
return RUNNING