Preloaded scene is no longer instantiating and not sure how to diagnose the issue

Godot Version

4.3

Question

I have a scene that is no longer instantiating. It was working before but some recent change must have caused it to break… Here’s the code snippet where it gets hit:
image

And where the resource gets loaded (in a globally loaded script)

The path is ok too:
image

Here’s what the global looks like in the inspector compared to other preloaded scenes…

So my question is how tf am I suppose to diagnose the issue? Is there a warning log that would help or anything?? I’ve read before that it could be corrupted scenes but again, how do I diagnose that myself?

Thanks

The error in the console:

The scene and all its nodes:
image

The .tscn file as text:

Both of which definitely have nodes…

Print out the value of Resources.weapon in the NewWeapon function.
The output will tell you if it is a valid node.

Note that pictures of scene trees and errors are good.
Pictures of code suck because we can’t cut and paste in reply.

1 Like

Ah yea, I should copy paste code snippets, thanks.

Well, a random shot in the dark of loading the scene within the function seemed to work… not sure why preloading the scene wouldnt work while loading does…

func NewWeapon() -> C_Weapon:
	var weapon_scene : PackedScene = load("res://Game_Objects/Weapons/Weapons/C_Weapon.tscn")
	var new_weapon : C_Weapon = weapon_scene.instantiate()
	temp_node.add_child(new_weapon)
	#var test = Resources.projectile.instantiate()
	if weapon_scene.can_instantiate() == false:
		printerr("RIP")
	return new_weapon

I will look into printing what you said out of curiosity… I’m not really satisfied with this fix.

(Changing it to load from preload inside my global References also works)

When the scene is loaded via load

	print(Resources.weapon)

Prints:
<PackedScene#-9223371864770868831>

Inspector shows:
image


When loaded via preload it prints:
<PackedScene#-9223371964343646838>

preload() inspector gives:
image

Pretty similar looking outputs- but load() is definitely working loading it as a PackedScene whereas preload is loading it as a generic object…? Bleh I have a feeling I should move on and not try to understand why preload is failing…

thanks though

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