I'm trying to get the cell data of a specific cell on a tilemap when hovering the mouse over it. However, I've got a Camera2D that allows me to zoom in and pan to different directions, which means that event.position is not getting the correct position in the world while the camera is offset or zoomed in. Does anyone have any solution for this?
#Getting the mouse position with regards to Camera2D zoom and offset
5 messages · Page 1 of 1 (latest)
I can account for the offset fairly easily by adding the camera offset to the position of the mouse but I can't figure out how to account for zooming.
get_viewport().get_mouse_position() should give you local screen coordinates
I think you could use get_global_mouse_position() in this case?
No matter how far the camera is zoomed it should give the proper global coordinates