Instantiation does not work

Godot Version

4.2.2

Question

im trying to add a PackedScene to the game scene but nothing happens

heres the code:

func _ready():
	var new_entity = entities[0].instantiate()
	new_entity.owner = get_parent()

add_child(new_entity)
after instantiate

1 Like

tried that, didnt work

extends Node2D

@export var entities : Array[PackedScene] = []

@export_group("Spawning Options")
@export var delay = 5000
@export var amount = 2

@export_group("Spawning Range")
@export var range_x = 1024
@export var range_y = 1024

# Called when the node enters the scene tree for the first time.
func _ready():
	var new_entity = entities[0].instantiate()
	get_parent().add_child(new_entity)


# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
	pass

full code

doesnt work as in not visible or no node at all ?
check Remote Tab

1 Like

yeah nothing

add

await get_tree().physics_frame

the first line of _ready() func

1 Like

how is that supposed to work

the node is ready but the export doesnt ready yet, hence spawned to nothing
or it’s just your parent not ready, so you spawn to nothing

read what it is physics_frame from scene tree:

1 Like

oh ok
thanks for the help

1 Like