Instantiate doesnt fully create scenes

last version of godot steam
so im trying to create simple procgen thingy and i have a “room” that has nodes and each nodes spawns a room in those room instances there s more nodes to spawn more room that is kept in check in code to not create infinte loops
the problem is that new instantiated rooms dont spawn with nodes for some reason

extends Node3D

var rooms_array : Array = [preload("res://prefabs/rooms/room1.tscn"), preload("res://prefabs/rooms/room2.tscn"),preload("res://prefabs/rooms/room3.tscn"), preload("res://prefabs/rooms/room4.tscn") ]
@export var max_rooms_pre_randit : int
@export var rooms_min_random : float
@export var rooms_max_random : float
func _ready() -> void:
	if !global.max_rooms_decided:
		global.max_rooms = int(max_rooms_pre_randit * randf_range(rooms_min_random, rooms_max_random))
		global.max_rooms_decided = true
	print(global.max_rooms, global.rooms_spawned)
	if global.rooms_spawned < global.max_rooms:
		print(global.max_rooms, global.rooms_spawned)
		try_to_spawn_room()
		global.rooms_spawned += 1
func try_to_spawn_room():
	var instance = rooms_array.pick_random().instantiate()
	add_child(instance)
	print("hello world i spawned a thing")

this i pretty much all the code and its in the spawn node
first room is not spawned but either just dragged into an editor

From what i see, There are a few issues that there could be, When instantiating scenes, everything in that scene will be spawned at the position it is in your scene, Meaning if you have build something far from center, it will be far from center.

Next thing, make sure that you have saved all your scenes, That way everything spawns as it should.

If that doesn’t work, please also try to post pictures of what the output is :slight_smile:

1 Like

all the scenes are saved and nodes are placed on the doorways
and also for some reason sometimes it doesnt even spawn the room
although all the rooms in rooms array have some kinda mesh in them and it is positioned correctly

and also it only prints the fact that it spawned smth 3 times so new nodes certenly dont get instantiated