Best practices for "selectable" elements in game

Godot Version

4.2.1

Question

I’m currently working on a grid-based top-down 2d game that has elements in the world I can select. So I can move the mouse over and click on items, and then something pops up in the UI when that thing is selected. So I have a sprite like this:

selector

The most straightforward way I can think of to have this sprite follow the mouse (snapping to the grid) and then go onto another sprite is to make it a Node2d in my scene node in my scene. However, this is a UI element and it feels like it should be in my CanvasLayer as a Control nodes. If I do that, however, it seems significantly more work to get it to the correct size and position in the scene, especially if I zoom in or out.

I’ve been having trouble finding other references to how this is most effectively done, but perhaps I’m using the wrong search terms. How “should” I do this? Conceptually it feels like I should use control nodes, but not using them seems easier. I just don’t want to get myself in a pickle later on.

@joyfulsquirrel Thank you for the advice. I just tried this out, and I’m seeing the same behavior which I had seen with adding a TextureRect to my canvas, which is that it stays the same size no matter how much I zoom. To be clear, my UI is not a child of my Camera2D – nothing is. And counterintuitively, I just tried to make my UI a child of my Camera2D and that didn’t change any behavior that I could tell.

So I wonder if I left out some critical details in my question, or if I’m doing something wrong?

Yes, I’m zooming the camera in and out, and eventually will be panning as well.

And thank you, you’re confirming that it’s not as clear-cut as I thought it was “supposed” to be. By putting my selector in world space with a Sprite2D, I think the display behavior will work without having to script it. I think that’s what I’ll do for this!