The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates. | Twitter

0 votes

I've been following the tutorial on changing scenes asynchronally (as seen here) and translating it to C#, however, the following errors occur:

  1. E 0:00:01.799 get_tree: Condition "!data.tree" is true. Returned: nullptr
  2. E 0:00:01.802 connectsignalawaiter: Parameter "p_source" is null.

When yielding, I run

 await (ToSignal(GetTree(), "idle_frame"));

as seen here
however the errors above happen right at that moment. What am I missing to properly load resources/scenes asynchronously?


   private async void ChangeSceneAsync(string path)
    ResourceInteractiveLoader ril = ResourceLoader.LoadInteractive(path);

    while (true)
        Error err = ril.Poll();
        if (err == Error.FileEof)
            Resource res = ril.GetResource();
        if (err == Error.Ok)
            float progress = (float)(ril.GetStage() / ril.GetStageCount());

        await (ToSignal(GetTree(), "idle_frame")); // Errors occur here
Godot version 3.4.2
in Engine by (41 points)

1 Answer

+1 vote
Best answer

I got this error once and the reason was that the node (where the script is running the GetTree()) was not inside the tree. You need to make this node a child of another. Another reason might be that you are using the constructor of this class instead of using the _Ready method.

by (255 points)
selected by

This was it. I had this function in an autoloaded Global.cs script thats why it couldnt find the tree.

I moved it to a node in a simple scene to test it quickly and now it loaded my resource properly.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.