bovido/scripts/move_to_target_action.gd
Mathilde Grapin 5970aa2ac2 Flip enemy and use blackboard
Use blackboard for destination.
2023-06-12 18:50:58 +02:00

17 lines
533 B
GDScript

class_name MoveToTargetAction
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