This is the testing Godot forums! All forum posts unique to this forum will be deleted! Please use the main forums here for any posts you want to keep. All forum rules still apply.

Exported Packed Scene Returning Null

martymarty Posts: 123Member
edited October 2018 in General Chat

At the top of a script, I'm exposing a packed scene in the inspector, like so:

export (PackedScene) var my_instance

Then, as per normal, I am populating the variable's inspector field with a valid TSCN file.

But then, in my _ready() function, when I try to access the my_instance variable, I get an error indicating that it is Null value.

I'm using this same script pattern in other scripts on other nodes without issue where it works just fine. It's a very common pattern, as you know.

So, why, oh , why, does this one occurrence not want to work?

Anyone see this before?

Best Answer

  • martymarty Posts: 123
    Accepted Answer

    Well, nevermind. The problem inexplicably fixed itself. I didn't change any code - just loaded a few different projects and then came back to the offending one and POOF, it suddenly worked as expected.

    Might just be a glitch but if it does it again, I'll file a bug report.

Answers

  • martymarty Posts: 123Member
    Accepted Answer

    Well, nevermind. The problem inexplicably fixed itself. I didn't change any code - just loaded a few different projects and then came back to the offending one and POOF, it suddenly worked as expected.

    Might just be a glitch but if it does it again, I'll file a bug report.

  • DrennynDrennyn Posts: 1Member

    Seeing the same behavior here, but loading other projects and going back to the offending one doesn't fix anything. This same exact concept worked fine when I ran through the "Creeps" tutorial where it's used to instantiate a specific Mob. When I try in a new project, I keep getting the exported PackedScene set to null even though the inspector clearly shows a scene loaded.

    I've cleared and reloaded the property in the inspector multiple times to no avail. However, I just tried setting the property to a "New PackedScene" and now seeing a non-null value. Back in the inspector, I reselected/reloaded the scene I really want, and now it's working.

    When I originally set the value, I drag/dropped the scene from the file explorer panel into the inspector. Thought maybe that had something to do with it...but now that's it's working, it continues to work regardless whether I drag/drop, or use the inspector dropdown to load the desired scene.

    Seems "wonky" but is working now.

  • MegalomaniakMegalomaniak Posts: 2,580Admin

    I have not tested this or anything, but from your descriptions it sounds like it could be a dependency graph/update issue. Would probably be helpful to see your code and how you instantiate the scenes..?

Sign In or Register to comment.