Best node for chess-like board coordinates?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By John97

I’m making a game with a board similar to chess’(but instead of squares, it uses hexagons). The board I have now consists of many individual Area2d nodes(cells) with a sprite and collision shape. I want the player to drag the pieces with the mouse and have them snap into place in a grid-like way. What is the best node to implement this behavior? If I want to use GridContainer, will I have to change something about the individual cells?

:bust_in_silhouette: Reply From: Bubu

GridContainer arranges nodes in a square grid, so it’s not helpful in case of a hexagonal grid.

For snapping, I would suggest that you set the position of the piece to be the position of the Area2D node under the cursor.

You can do this by setting pickable to true and processing the Mouse Input.