Instance glitch

Godot Version

4.5

Question

when I instantiate a model into the scene via code, there is a glitch where the model will appear for a few milliseconds, before going to the proper position.

in my case, i have set on the model i created to run the animation, when the model is get instance

#n_1.gd
extends Node3D

@onready var anim : AnimationPlayer = $AnimationPlayer

func _ready():
	anim.play("numb_in_001")

but as you can see in the video the model does not immediately play the animation, instead it will return to the default position for a few milliseconds before playing the animation.

this is how i call the model into other scene :

# number_manager.gd
@onready var boss_numb := $boss_numb/marker_boss

var active_models = []

func display_boss_digit(digit: int):
	var num_path = NumberDataBase.BOSS_SECTION_NUMB[digit]
	var scene = load(num_path)
	var instance = scene.instantiate()
	
	boss_numb.add_child(instance)
	active_models.append(instance)

I really don’t know what the cause is.

You should probably either have a starting position or hide the mesh as soon as you spawn it. When you instantiate a child its position will be at the world origin by default, so that might be your issue. So either do

# number_manager.gd
@onready var boss_numb := $boss_numb/marker_boss

var active_models = []

func display_boss_digit(digit: int, pos: Vector3):
	var num_path = NumberDataBase.BOSS_SECTION_NUMB[digit]
	var scene = load(num_path)
	var instance = scene.instantiate()
	instance.position = pos

	boss_numb.add_child(instance)
	active_models.append(instance)

with pos being the starting position of the animation.
or

# number_manager.gd
@onready var boss_numb := $boss_numb/marker_boss

var active_models = []

func display_boss_digit(digit: int):
	var num_path = NumberDataBase.BOSS_SECTION_NUMB[digit]
	var scene = load(num_path)
	var instance = scene.instantiate()
	instance.visible = false

	boss_numb.add_child(instance)
	active_models.append(instance)

and make it visible the frame after you set its position in your animation.