Cant create an instance of a scene if an instance of the same scene is already present

I have had good success asking people to makw repos on github in order to help them as well.

That is easier and safer than messing with zips.

2 Likes

(https://github.com/baileyhalfcat/procgen-test)
for some reason it breaks when i re launch the file so i think i need to remake the project
edit 2 now i have a new problem each time i reload the project it completely brakes apart

Hi, I made some pull requests on your github. I removed the references to external resources and that should allow the project to open again.

I think those errors were happening because a file name was changed somewhere and Godot was not able to reconcile it

I think you have a recursive problem, room1.tscn requires random generation.tscn and vice-versa which cannot be satisfied. Instead of using an array of packed scenes, you could try using the filepaths and loading the rooms at runtime. This allows the editor to not care about loading entire rooms just to open the project.

I would edit procgen.gd like so

extends Node3D
@export_file("*.tscn") var rooms_array : Array[String] = [] # filepaths
@export var max_rooms_pre_randit : int
@export var rooms_min_random : float
@export var rooms_max_random : float

func try_to_spawn_room():
	var prefab: PackedScene = load(rooms_array.pick_random()) # using load
	var instance: Node3D = prefab.instantiate()
	add_child(instance)
	print("hello world i spawned a thing")
1 Like

turns out the whole thing was coz of preload() so yea u re correct

I added the default environment and sun to show see it better. Then I added some extra rooms wihtout any generators so it could attempt loading the other sides, scenes with only a mesh instance of random shapes.

Fun code!

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.