Topic was automatically imported from the old Question2Answer platform.
Asked By
codelyoko373
Pretty much as the title says. I’m trying to snap a node/player to the center of a 64x64 grid just to make my life easier for some things. The issue is whenever I try, it only snaps to the corners or sides. Is this a bug or is there some setting I haven’t enabled?
I think there’s a way to make the center of the sprite the reference point.
You could configure snapping, can be found on top with 3 dots
or disable snapping by clicking on the magnet icon on top of your scene
or change the position via inspector
Godot snaps to the grid guidelines and not the cells between them. So you won’t snap to the middle of the square that you’re dragging to. That’s because you’re snapping the position of the object (that little symbol in the centre) to a grid, which is a specific position (the line).
There are two aspects to solving this:
Scene root position
When viewing a scene (like your player), if you click on the root node (at the top of Scene) you’ll see a red cross indicating the root position. For side-view games, we want this on the bottom/feet of the object.
Set the root position of your objects to their feet/bottom to make it easy to snap to floors. With top-level object selected, you should see the root (red cross) on the red line (x-axis). See short video here.