bovido/scripts/move_to_target_action.gd

17 lines
431 B
GDScript

class_name MoveToTargetAction
extends ActionLeaf
func before_run(actor, _blackboard):
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
func after_run(actor, _blackboard):
actor.animation_player.stop()