Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Accessing global_position before a scene instance is added to the scene tree can cause its position to reset to zero #75676

Closed
reikken opened this issue Apr 5, 2023 · 2 comments · Fixed by #75509

Comments

@reikken
Copy link

reikken commented Apr 5, 2023

Godot version

4.0.2

System information

Windows 10

Issue description

If a script accesses the global_position of an object instantiated from a packed scene before it's added to the scene tree, and then once added to the scene if its global position is modified by anything (including the physics engine) before its position is modified, it ends up at the origin, regardless of where it's placed in the editor. And for objects instantiated via script, regardless of what its position was set to before adding it with add_child()

The bug does not occur if the object is not a scene instance. Its position is preserved.

Steps to reproduce

instantiate a scene
access its global_position
add it to the scene tree
modify its global position

Minimal reproduction project

min.zip

@reikken reikken changed the title Accessing global_position before a scene instance is added to the scene tree can its position to reset to zero Accessing global_position before a scene instance is added to the scene tree can cause its position to reset to zero Apr 5, 2023
@kleonc kleonc added this to the 4.1 milestone Apr 5, 2023
@playemgames
Copy link

Hate to necro this one, but I saw this same behavior happen with a Node3D in a pretty bare scene with instanced scenes into a main scene. I positioned the instanced scenes into the main, then on play they all start at Vector zero. This was in 4.1.1 stable.

@Shawn-Akii
Copy link

So there`s no way to fix this bug?what if I have to deal with it,what should I do?add as child node instead of instance?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants