+1 vote

Well i dont get it.

i can move my camera by clicking the mouswheel and draging the mouse
but also i can place tiles by clicking left mousebutton

now the tiles will appear annywhere but not there where the camera is.

this is what i wrote:

func _input(event):
if Input.is_action_just_pressed("mb_left"):
    pressed_at_position = get_viewport().get_mouse_position()
if Input.is_action_pressed("mb_left"):

the problem is that icant use global mouse position. dont know why. but he sais there is none such function in base viewport

i dont have a idea how to put my tiles where i realy click at

in Engine by (68 points)

Is this in 2D or 3D?

It's in 2d :)

1 Answer

+1 vote
Best answer

get_viewport().get_mouse_position() gives you coordinates where 0,0 is the top left of the screen, not the origin of the scene tree. get_global_mouse_position() is probably what you want - what is the exact error message you receive when trying to use that?

(relevant question that gives an out of date answer)

by (629 points)
selected by
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.