Hi,
I made a custom block builder in the world (like a tile map), and all was working good until I added pan to my camera. As I didn´t have any idea how to make it work I followed a tutorial from Kids Can Code to make the pan:
http://kidscancode.org/godot_recipes/2d/touchscreen_camera/
The problem is that now, when the camera moves I can´t get the block at the position of the mouse, there is always a big offset.
The code is simply:
if event is InputEventScreenDrag:
blockToBuild.position = event.position
But when adding pan, I can´t get the block following de mouse/touch, I tried all this things:
blockToBuild.global_position = event.global_position
blockToBuild.position = get_mouse_position()
blockToBuild.global_position = get_global_mouse_position()
blockToBuild.position = get_viewport().get_mouse_position()
blockToBuild.position = make_input_local(event).position
lastBlockBuilt.position = to_global(event.position)
lastBlockBuilt.position = event.relative
And always happen when moving the camera with the pan. I thing the problem is in this line from the camera (I attached the link):
position += event.relative.rotated(rotation) * zoom.x