0 votes

So i have this node that has a child, let's call this child "node A", so then i remove node A from its parent node and i add it as node's A child.The problem is that when i reparent child's A former parent its shifts it position a bit .How do i prevent this from happening and why it happens?

asked Oct 13, 2019 in Engine by IndigoGames (70 points)

Please avoid uppercase titles, it sounds like you are screaming

1 Answer

+1 vote
Best answer

When scripting you have 2 ways to change a position, by using position or by using global_position.
position is relative to the parent, so when a node moves, it moves the origin of its children.
global_position is relative to the root's origin(i believe) so it stays the same even if the parent's origin is changed

i dont know if you can disable that but you can reset the node's position everytime you move it to the global position you want it to have

answered Oct 13, 2019 by rustyStriker (1,079 points)
selected Oct 13, 2019 by IndigoGames
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.