0 votes

Hi, I'm trying to follow the formula for zooming towards a point here https://godotengine.org/qa/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 tolocal is because the centerpoint is in global position.
But after printing tolocal(centerpoint), 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

in Engine by (42 points)

1 Answer

0 votes

-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.

by (4,088 points)

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

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.