Is there a way to view selected gridmap cell coords in the editor?

Godot Version

4.4.1

Question

Like the title says - is there any way to see a selected cell’s local map coordinates in the inspector or GridMap editor? I can manipulate things with map_to_local() and the inverse all day long programmatically, but actually finding the coordinates I’m trying to move things to is a huge pain (currently I just have my player character report their position every turn during debugging and working from there). I feel like I’m missing something, but I’ve been all over the editor UI and come up completely dry. It seems like there should be some toggleable view gizmo that reports the current selected cell’s coordinates at the y-layer selected in the Gridmap editor that I’m missing tucked away somewhere.

Not exactly what you asked but you can see the map coordinates of the cell on which the cursor is at the left bottom corner of the game view.

TileMap should be selected on the bottom panel.

Note that I’m using v4.5

That would totally work for a TileMap but I’m using GridMaps, and the same feature for GridMaps doesn’t seem to exist. :face_with_spiral_eyes:

e: I did update to 4.5 as well, I guess, still nothin’.

Sorry, I totally misunderstood your question.

I don’t think there is a ‘native’ way to show it.

But I also see that there is a GridMapEditorPlugin node and it has a method of get_selected_cells(). So tecnically, it may be possible to write a simple editor running script or a plugin. But I don’t know how to do that. Maybe someone else can help with it.

1 Like

Oh, thank you!!! That looks like exactly what I needed - I was up until 3AM or so trying to make a plugin work with a raycast in the Spatial editor window but it was really finicky and felt like I was still a ways off. I’ve only had a couple minutes to poke at this between day job meetings, and it seems like it’s harder than you’d intuitively think to get access to the current active GridMapEditorPlugin, but once I get that sorted out I can absolutely use its methods to report what I’m looking for.

Yeesh, okay - I finally got access to the GridMapEditorPlugin with this:

	var root = get_editor_interface().get_resource_filesystem().get_node("/root")
	var grid_map_editor = root.find_children("", "GridMapEditorPlugin", true, false)[0]

From there it was simple enough to just use get_selected_cells() and pop the first result into a few labels (I’ll add some handling for multiple selections later):

Anyway, thanks a ton for your help!!! I might clean this up and toss the plugin on the AssetLib later, it’s weird but extremely useful for some methods of manipulating GridMaps.

1 Like

Did you every make this? Or can you share code? I am struggling to align editor coordinates with code

Sorry, I ended up getting a bit sidetracked doing a bunch of Blender tutorial courses. :sweat_smile: I’ll try to get it on the AssetLib this week and reply again here when I do!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.