Set child position to a specific global position

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

Hello,
in my Control parent “Project” i want to set an GridContainer child “tasks” to a specific global position; in “Project” i call in the _ready() function:

tasks.set_global_position(Vector2(rect_size.x, 0))

I expect that for all “Project” object instances, each corresponding “tasks” child has the exact same position so they are overlapping. Unfortunately this is not happening: The “tasks” child appears always to the right of the “Project” instance.

Am i getting something wrong or why is this not working?
Thanks in advance!

PS: here is the whole project: GitHub - Wendelstein91/Goalify0300
The problem occurs in Project.gd.

This is still unsolved for me.
I updated the project: please help me…

ErdnussMaus | 2022-05-04 17:51

Hello,
can you provide your project on github again or make a Screenshot of your Scene Tree?

juppi | 2022-05-07 13:32

Hello juppi,
whats the problem with the link above? It should work.

ErdnussMaus | 2022-05-08 07:12

Oh yeah. I see. There’s a dot at the end of the URL.

So, I think that doesn’t work with that kind of Node.

The documentations says:

Grid container used to arrange Control-derived children in a grid like
layout. … … GridContainer will arrange its Control-derived
children in a grid like structure, … Note: GridContainer only works
with child nodes inheriting from Control. It won’t rearrange child
nodes inheriting from Node2D.

https://docs.godotengine.org/en/stable/classes/class_gridcontainer.html

juppi | 2022-05-08 10:08

Thank you for your respond, i removed the dot from the link.
The point is, i do not want to rearrange children of the GridContainer,
i just want to set the position of a GridContainer which is a child.
The strange thing with my project is:
Project instances have one own GridContainer and task instances also have one.
The positioning of the GridContainer of tasks works while that of the projects child GridContainer doesnt work.

In short:
-Project_instance
-GridContainer (positioning false)
-Task_instance
-GridContainer (positioning ok)

you can simply check this if you run the project, add 2 projects by clicking “+”. Then attach 2 tasks to each of this projects by clicking “+” button of the projects and then do the same for the four tasks to add todos to each task. You will see that the tasks of project two will have an y-offset that todos of tasks will not have.

ErdnussMaus | 2022-05-08 10:45