(From me in the future: In writing this, I found a workaround that assigns ItemInfoResource during runtime, so this isn't blocking me. But I just wanted to understand the reasoning behind this to understand the engine a little better.)

I have a scene that is an "Item". It's meant to be a generic "base" item. In the Item script, I have a reference to a ItemInfoResource that I can then use to give it stats, a sprite, and most importantly a PackedScene of the particular "Item" so I can instantiate these Items in my world.

However, once I assign the my "Item" scene to the PackedScene export variable, then it gives me the error:
Recursion detected, unable to assign resource to property

So to recap:

  • I give my scene a ItemInfoResource
  • I give my ItemInfoResource a reference to the Item scene
  • I get a recursion error.

But to me this isn't recursion, because I'm merely giving it a reference. Are these somehow instantiated because it's an @export variable? Or is it Godot just trying to be cautious and stopping a case that isn't actually a problem?

So just so I'm sure what you're saying:

  • You have a scene. The root node is an Item. That item holds an ItemInfoResource.
  • The ItemInfoResource has an @export some_name:PackedScene variable.
  • You assign the Item scene to its own Item's ItemInfoResource's PackedScene variable.

Is that correct? This would indeed cause infinite recursion, because the PackedScene is loaded when the ItemInfoResource is loaded which is when the Item is loaded which is when the PackedScene is loaded which is when the ItemInfoResource is loaded which is when the Item is loaded which is when the PackedScene is loaded which is when the ItemInfoResource is loaded which is when the Item is loaded which is when the PackedScene is loaded which is when the ItemInfoResource is loaded which is when the Item is loaded which is when the PackedScene is loaded which is when the ItemInfoResource is loaded which is when the Item is loaded which is when the PackedScene is loaded which is when the ItemInfoResource is loaded which is when the Item is loaded which is when the PackedScene is loaded which is when the ItemInfoResource is loaded which is when the Item is loaded which is when the PackedScene is loaded which is when the ItemInfoResource is loaded which is when the Item is loaded which is when the PackedScene is loaded which is when the ItemInfoResource is loaded which is when the Item is loaded which is when the PackedScene is loaded which is when the ItemInfoResource is loaded which is when the Item is loaded which is when the PackedScene is loaded which is when the ItemInfoResource is loaded which is when the Item is loaded which is when the PackedScene is loaded which is when the ItemInfoResource is loaded which is when the Item is loaded which is when the PackedScene is loaded which is when the ItemInfoResource is loaded which is when the Item is loaded which is when the PackedScene is loaded which is when the ItemInfoResource is loaded which is when the Item is loaded which is when the PackedScene is loaded which is when the ItemInfoResource is loaded which is when the Item is loaded which is when the PackedScene is loaded which is when the ItemInfoResource is loaded which is when the Item is loaded which is when the PackedScene is loaded which is when the ItemInfoResource is loaded which is when the Item is loaded which is when the PackedScene is loaded which is when the ItemInfoResource is loaded which is when the Item is loaded which is when the PackedScene is loaded which is when the ItemInfoResource is loaded which is when the Item is loaded which is when the PackedScene is loaded which is when the ItemInfoResource is loaded which is when the Item is loaded which is when the PackedScene is loaded which is when the ItemInfoResource is loaded which is when the Item is loaded which is when the PackedScene is loaded which is when the ItemInfoResource is loaded which is when the Item is loaded which is when the PackedScene is loaded which is when the ItemInfoResource is loaded which is when the Item is loaded which is when the PackedScene is loaded which is

Error: uncaught exception: out of memory |

6 months later

Guys! Im at the same problem. What would be the solution?

  • xyz replied to this.

    kuligs2 What would be the solution?

    Avoid circular referencing.