Godot: Node briefly appears at scene origin when instanced in _ready

Created on 8 Nov 2019  路  8Comments  路  Source: godotengine/godot

Godot version:

3.1.1

OS/device including version:

Linux 5.3.8-arch1-1 x86_64 GNU/Linux

Issue description:

If PackedScene is instanced during _ready and the origin is changed, it briefly appears at (0,0,0) before moving to its set position.

This is very similar to #23340, except:

  1. #23340 was supposedly fixed in 3.1, this is not
  2. #23340 applies to RigidBodies, this applies to a MeshInstance and possibly other types
  3. This applies _only_ during _ready. If instanced during _physics_process, it doesn't seem to happen

Steps to reproduce:

extends Spatial

export(PackedScene) var scene

func _ready():
    yield(get_tree().create_timer(5.0), "timeout")
    var obj = scene.instance()
    obj.global_transform.origin = Vector3(1, 1, 1)
    add_child(obj)

Minimal reproduction project:
example.zip
out

bug core

Most helpful comment

Tried both Godot and Bullet, it reproes in both.

All 8 comments

I came across this in a StackExchange post.

This is probably not related, but does this happen with both Bullet and Godot physics? You can change the physics engine in the Project Settings.

Tried both Godot and Bullet, it reproes in both.

Does it happen if you set position after add_child?

Yes, the order doesn't seem to matter. I also tried called_deferred to
set the position. Same deal.

On Thu 11/07/19 06:17PM, Tomek wrote:

Does it happen if you set position after add_child?

--
You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub:
https://github.com/godotengine/godot/issues/33435#issuecomment-551353891

I also tried with using timer, but still didn't work

var asteroid_instance = asteroid_scene.instance()
asteroid_instance.transform.origin = spawn_position

yield(get_tree().create_timer(1), "timeout")
add_child(asteroid_instance)

Temporarily fixed by hide mesh right after instantiated, and then used coroutine to wait very short time and show mesh back. Hope fix this soon.

Could reproduce on 3.1.1.stable.official, but not on 3.2.custom.build. 0e54b2d43 (master).
Note that to be able to see it clearly and reliably, I had to set debug/settings/fps/force_fps = 3.

This code does not exhibit the issue on either version, so it is clearly related to the timer:

func _ready():
    yield(get_tree().create_timer(5.0), "timeout")
    yield(get_tree(), "idle_frame") # or "physics_frame"
    var obj = scene.instance()
    obj.transform.origin = Vector3(1, 1, 1)
    add_child(obj)

Checking scene_tree.cpp's history (where SceneTreeTimer is defined), I can say that this issue has probably been fixed by #30919.

Going to close this as I think it is fixed, but feel free to reopen/comment if you have evidence to the contrary.

Was this page helpful?
0 / 5 - 0 ratings