0 votes

I encountered a strange problem involving setting metadata that I can't find any cause for. Was wondering if anyone had any suggestions on what to check.

If a parent node at initialization I call setmeta("data", 1). I check it with getmeta, and it is there.

However in the children nodes, they can't see to see the meta data. I get_parent(), it is the correct node, but it has none of it's meta data. Even when deferring and looping, it never shows up.

So the parent will report having, the children can't find it.

In another scene I made weeks ago using this method, it is identical code, and actually works just fine...

I'm starting to suspect some sort of internal bug. Anyone have anything to add?

Thanks. ^_^

in Engine by (5,276 points)

I did a quick test with Controls and get_parent().get_meta() works fine, metadata was added by parent on ready, got the metadata with a button.

Are you adding metadata on init, after init, on ready?

It's being added on init(). I one scene it works fine. In another the same set up does not. The output reports that the meta data is there in any code attached to the parent. However, none of the children, regardless of timing can find that meta data.

They are referencing the same constants. It is rather strange.

At the moment I've just changed everything to using member variables instead, with some special logic to test if the variable exists. I can't replicate it in any normal nodes or conditions. It seems to be happening in my custom plugin nodes, so maybe there is some issue there.

If you can be bothered, maybe check for me if a set of separate plugin custom nodes fail this on your end as well.

CustomA (init -> set meta) child CustomB (getparent().getmeta())

Plugins hate me but will try ^_^;

Thanks. Hopefully it's a quirk of custom nodes.

Tried with 2 custom nodes that found on a messy testbed project and works.

What I did is set_meta on init of the parent, then get_parent().get_meta on a function of the child, it works even when called on _ready.

Just realized I have no idea of how to instance custom nodes by code o_O

Hmmm, I guess I don't know then. Maybe something deeper was conflicting, I am using quite a bit of tool code, and sometimes the errors don't really manifest where you would expect. Everything runs fine though now that I've replaced all the meta data calls with variables.

As far as instancing custom nodes, I think it's just editor eye candy the way they're presented. Instancing a node at runtime would be just creating the node and adding the script to it before adding it to the scene.

I imagine that's all it does in the editor, but registering it via the plugin class gives it an icon and allows you to quickly create them from the node menu.

Try setting meta on ready, to see what happens and reduce the scope of the problem.

And using ready should be the same as init because custom nodes are always ready.

I believe the issue was in some hidden tool mode issue. I've fixed certain other seemingly unrelated issues, and the problem has vanished.

It works fine as init and in ready again. I suspect something in the tool code were causing issues with how these nodes were entering the scene tree behind the scenes and not exactly reporting them.

Please log in or register to answer this question.

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.