17 lines
429 B
GDScript3
17 lines
429 B
GDScript3
|
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()
|