2023-06-12 16:48:35 +02:00
|
|
|
class_name MoveToTargetAction
|
|
|
|
extends ActionLeaf
|
|
|
|
|
2023-06-12 17:58:06 +02:00
|
|
|
func before_run(actor, _blackboard):
|
2023-06-12 16:48:35 +02:00
|
|
|
actor.animation_player.play("walk")
|
|
|
|
|
|
|
|
func tick(actor, _blackboard):
|
|
|
|
var delta = get_physics_process_delta_time()
|
|
|
|
actor.position = actor.position.move_toward(actor.destination, delta * actor.speed)
|
|
|
|
|
|
|
|
if actor.position == actor.destination:
|
|
|
|
return SUCCESS
|
|
|
|
return RUNNING
|
|
|
|
|
2023-06-12 17:58:06 +02:00
|
|
|
func after_run(actor, _blackboard):
|
2023-06-12 16:48:35 +02:00
|
|
|
actor.animation_player.stop()
|