to_local() error

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Vincent William Rodr

Hi, I’m trying to follow the formula for zooming towards a point here https://forum.godotengine.org/25983/camera2d-zoom-position-towards-the-mouse but instead of the mouse, it’s the center point between two drags.
The formula (similar to the link’s formula) is this:

position -= (to_local(center_point) - window/2) / (3/4) * (resd)

The reason for why i used to_local is because the center_point is in global position.
But after printing to_local(center_point), the result is this

(-1.#IND, -1.#IND)

Why did this happen? The Script is attached to a Camera2D and the version is Godot v3.2.2 anyways

:bust_in_silhouette: Reply From: klaas

Hi,
-1.#ind means the number is iinvalid. This usualy happens when difiding by zero.
So, how do you calculate crnterpoint? I think the error spawns from there.

it simply is the sum of the two global starting points of the drags, divided by 2

Vincent William Rodr | 2020-09-05 02:08