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?

in Engine by (73 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

by (1,190 points)
selected by
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.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.