class_name MoveToDestinationAction 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 func after_run(actor, blackboard): var destination = blackboard.get_value("destination") destination.y -= actor.Y_SPAWN_OFFSET var cell = actor.tile_map.local_to_map(destination) actor.tile_map.set_cell(0, cell, 0, Vector2i(0, 0), 0) # debug purpose