OK, what is the secret to basic centering?

Godot Version

4.3

Question

I am simply trying to have the child node centered onto the parent node. This is extremely basic stuff in other languages/guis, but the godot editor doesn’t seem to run with standards.

In other languages you can simply set the child object’s location to ‘center’. Easy peasy.

Easy to replicate:

  1. Create a Node2D.
  2. Plop anything on the node… a panel, label, button… doesn’t matter.
  3. … profit?

I figured I’d use anchors… but anchors in Godot means something different than other tools. Normally, you would set the anchors on each side of the child object ± pixels or percentages. It’s a bit of a way to work around hackney positioning. But godot’s anchors are… based on object’s pieces and not the normal relativity to the parent object.

Has any one found the secret magic for this basic situation in Godot?

Can you elaborate on what part of the documentation below you followed and it did not do as intended?

Yeah, anyone who read the docs found the “secret”: Using Containers — Godot Engine (stable) documentation in English

It turns out that the documentation isn’t applicable to Node2D unfortunately. Only to Control nodes. Once I created a new parent node based on User Interface (Control) and not on Scene 2D (Node2D), everything worked according to the documentation.

In short, it means I need to make my game based on Control and not Node2D. Ah well, good to know!

1 Like

Per the post you replied to, I was using Node2d… which the documentation you linked to does not address.

Just add a dummy Control node and put your Node2D inside