0 votes

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?

Godot version 3.2.3.stable.official
in Engine by (37 points)

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.

After upgrading to 3.4, this now works. Thanks for the suggestion!

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.