Can't reference any scene when using @export with a PackedScene typed array (Array[PackedScene]).

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Sh1co

I am updating my project from Godot 3.5 to 4.0.
I used to have an exported array that I used to store a list of levels:

export(Array) var levels

Which through the GUI I’d drag and drop scenes(levels) and set each one to PackedScene.

Right now, it looks like this

@export var levels : Array[PackedScene]

However, whenever I try to drag and drop a scene(level) in, it gives me this errors

Attempted to set an object of type ‘PackedScene’ into a TypedArray, which does not inherit from ‘Node2D’.

core/variant/array.cpp:413 - Condition “!_p->typed.validate(value, “set”)” is true.

I tried it with multiple scenes and even created new ones which directly inherit from Node2D but nothing worked.

Any help would be appreciated.

I tried this and it seems to work fine, but I don’t have your PackedScene to verify; I just created another scene and dropped them into the array (it also works if I drop the parent scene into itself).

So, what’s a PackedScene look like in your project and can you share it?

spaceyjase | 2023-03-18 19:51

I tried it again after restarting the engine and it worked fine.

The PackedScene that I was trying to was of a gameplay level that extends game level that extends Node2D. But maybe it was just a bug, because I did try it with new scenes before and it gave me the same error.

Anyways, thanks a lot replying :smiley:

Sh1co | 2023-03-19 01:12