Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Nephtis |
If I have the following structure:
- Top node
- Node A
- Node B (has a NodePath reference to Node A: "../Node A")
- Node C
And then change it to this:
- Top node
- Node A
- Node C
- Node B (NodePath reference to Node A automatically changes to: "../../Node A")
Although the new NodePath
looks correct, it doesn’t work at runtime, saying it can’t find Node A
. To make it work, I have to manually set the NodePath
again, but in theory there shouldn’t be any difference between what I set it to and what it automatically changes to when it’s moved.
Am I using NodePaths
incorrectly? Or are they unable to handle this kind of operation?
This works fine:
extends Node
export(NodePath) var a: NodePath
func _ready():
print(a)
var node = get_node(a)
print(node.name)
Assuming A
is assigned in the editor, moving B
around maintains the correct reference.
edit: tested on 3.4. Perhaps consider an upgrade or show more of your project structure/scripts.
spaceyjase | 2021-12-09 09:19
After upgrading to 3.4, this now works. Thanks for the suggestion!
Nephtis | 2021-12-10 07:53