So I am trying to connect my "selector" with my "map" so that when I select a tile I can create a visual indicator. I may also implement the tile coordinates into movement further down the line. However, the problem I have is that the tile coordinates that I get are relative to the camera position, so that the top left of the screen is always (0,0). However, I want (0,0) to always be the first placed tile in the tilemap regardless of where my camera moves. Is there a way to get tile coordinates based on global position rather than local position of screen?
extends TileMap
signal selectShip(globalPos)
func _input(event):
if event is InputEventMouseButton:
if event.button_index == MOUSE_BUTTON_LEFT and event.is_pressed():
var global_clicked = event.position
var tile_pos = local_to_map(global_clicked)
emit_signal("selectShip",tile_pos)
This is the code that I've been working with so far. I haven't found any type of global_to_map() and I can convert the coordinates into a global position, but I can't figure out how I find the tile coordinate not relative to screen position.