Mathilde Grapin
1aed988149
Add the Beehave addon. Make the enemy do the same thing as before but with a behavior tree.
17 lines
429 B
GDScript
17 lines
429 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()
|