Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | 358JH33E |
I am trying to pass variables between two scripts without using AutoLoad/Singletons. The scripts are attached to two nodes as illustrated below:
o
|-o Node_A, [SCRIPT_A]
|-o Node_B, [SCRIPT_B]
When I try to use get_parent().get_node() in one script to access variables from the other script, I am given autofill options that indicate that Godot knows what I am trying to access.
For example, if in SCRIPT_A, I write get_parent().get_node("Node_B")
and put a .
decimal at the end, I am suggested variables from SCRIPT_B.
Unfortunately, when I write something using these suggestions, like get_parent().get_node("Node_B").var_from_script_b
, I get the following compiler error:
- Invalid get index 'var_from_script_b' (on base: 'Nil').
- get_node_or_null: Can't use get_node() with absolute paths from outside the active scene tree.
Again, I am looking for a solution that does not use AutoLoad. Any help I can get would be greatly appreciated!