0 votes

Godot3,1/Windows10
While passing variables between 2 Sibling Nodes/Scripts ,the values passed are "NULL".ie the values are not getting passed.
As this is a non-persistent situation, I do not wish to use Autoload.

Sample Call - Node1/Script1/Var1 to Node2/Script2/Var2

  var Var2 = get_Node(../Node1).Var1

The value passed above to Var2 is "NULL" ,
I have tried using _init() to instance the variables before assignment but still the values don't get passed.
How can one pass variables between 2 sibling nodes in a non persistent situation?

in Engine by (49 points)

Usually, I would use the parent node to indirectly communicate with the sibling node. tell the parent what to do, have the parent pass that data along to the sibling, then et them process it.

In a perfect world, child nodes would simply implement behavior and all the interaction would be through the parent node.

1 Answer

0 votes

Introduce your variable like this: export var Var1
Now you can reference it your way.

by (28 points)
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 webmaster@godotengine.org with your username.