For the life of me I can't seem to figure out how to get my sprites to move to the correct position. Everything works while moving the camera but adding zoom into the mix just really messes everything up.
When the Actor node detects a LMB click in the _input()
method it creates a path to use for to use for pathfinding
func create_path_to_destination(
event_position: Vector2,
camera_position: Vector2 = Vector2(0,0)
):
path = Navigation2d.get_simple_path(get_position(),
event_position + camera_position)
Then on every _physics_process(delta)
update I run the following code to move the character along the path
func move_to_destination(delta: float) -> void:
var distance_to_walk = Stats.current_movement_speed * delta
while distance_to_walk > 0 and path.size() > 0:
var distance_to_next_point = position.distance_to(path[0])
if distance_to_walk <= distance_to_next_point:
# warning-ignore:return_value_discarded
move_and_slide(
position.direction_to(path[0]) * Stats.current_movement_speed)
else:
path.remove(0)
distance_to_walk -= distance_to_next_point
Again, this all works perfectly fine even if I move the camera but after zooming in or out is when this begins to break.