–2 votes

has u can see the block don't go to the same position of the cursor
but if the camera is in a certain position i can place block correctly

how to fix that

https://we.tl/t-wvxRNC7XQR

Godot version 3.3.2
in Engine by (25 points)

1 Answer

0 votes

The link you sent has expired. And the description is not clear, so I can't guarantee fitting answer.

From what I can understand, you need to have blocks placed in the position of the mouse cursor, but if you move the camera to a different place, it's doesn't adjust to it.

I'm assuming that you use this code for getting mouse position:

get_global_mouse_pos()

It gives you global mouse position. And when the camera isn't lining up, it will be incorrect.

To get mouse cursor position relative to camera, use this:

get_viewport().get_mouse_position()
by (97 points)
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 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 webmaster@godotengine.org with your username.