How to align two objects' centers or snap to center?

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

When in the godot editor viewport, how can I:

  1. Align two selected objects (preferably by their center) either horizontally or vertically?
  2. Snap one object to another object with respect to their centers?

to 2): When I activate snapping, objects snapping seems to consider the top left point of each object, I want to consider the objects’ centers. So that after snapping, let’s say vertically, the selected object’s center y coordinate is the same as the snapped to object’s center y coordinate.

Thanks in advance, have a nice day!

This will probably achieve what you want, but it’s not what you want. When I need to align objects vertically or horizontally, I usually follow these steps:

  • Go to the Transform tab.
  • Copy the X or Y value of the object whose position you want to replicate.
  • Paste the copied value into the X or Y position of the object you want to align.

An Alternative good when you need to align multiple nodes at the same time:

  • you can select both objects (first the object you don’t want to move, then the second object), and then modify the X or Y position by 1 pixel. This will align the X number of nodes.
  • Once they are aligned, you can modify the position back to the original value to set them exactly where they were originally. For example, if you want to position them at 1527, you can change the value to 1527.001 and then back to 1527. This will align all the nodes.

I hope this helps!

crossbito | 2023-06-10 01:18

Thanks for the reply. The methods you mention do not solve the problem in the sense that they both align with respect to to top left corner of the objects. I want to align them with respect to their centers. I could of course compute the appropriate position to have the centers aligned, but I was wondering if there is any way to do this in the editor directly.

3DWizard | 2023-06-10 22:07