I have noticed something counterintuitive about Godot paths I kind of overlooked until now - the root node is accessed via "/root" path, rather than just "/".

In my mind, a "/" path is pointing at the root. It seems to be pointless to specify "/root" there unless the path can also contain "/nonroot", or some other elements - but then "/root" would not have been the root.

What's worse, GetNode() does not report the "/" path as invalid, and neither PrintTree(), nor inspecting the remote tree in the editor, which are often recommended for the path debugging, reveal the mistake.

I am considering reporting this as an issue, but would like to hear some opinions first. Perhaps having the path constructed this way has some uses I am not aware of, or maybe this has been discussed somewhere before?

    Rpahut / doesn't point to any nodes. It points "between nodes". Putting it at the starts of path points to "before root node"

    Rpahut In my mind, a "/" path is pointing at the root.

    On Linux, "/" is the path for the root directory. The Godot scene tree doesn't have directories, only nodes, so the analogy doesn't fit. I suppose that "scene tree directories" could be created as a new kind of object, but I don't know whether that would be useful.

    If you look at the runtime scene tree using the Remote tab, there actually is a node named "root", and its path is "/root".

      DaveTheCoder Linux paths do not apply, right, but path is not just a linux thing, it is a general concept. Conceptually, a directory is merely a node in a tree that contains other nodes. For the purposes of Godot paths, a node is a directory.

      What path do you get when you Copy Node Path for a remote root, or actually for any of the nodes there? In 3.5 I am unable to get a complete valid path this way.

        Rpahut In my mind, a "/" path is pointing at the root. It seems to be pointless to specify "/root" there unless the path can also contain "/nonroot", or some other elements - but then "/root" would not have been the root.

        You answer your own question perhaps... Check the remote tab while running the project, make use of some globals too. Maybe root is not what you might have expected and perhaps it even has siblings...

        Rpahut This is just a matter of syntax. Since node path is basically a list of node names, and root too is a named node whose name you can actually change, the devs decided to use /name instead of just / to specify the root node. I don't see how this can be a problem in any way, other than annoying you because you're used to syntax from directory systems that have nameless roots.

        Rpahut What path do you get when you Copy Node Path for a remote root, or actually for any of the nodes there? In 3.5 I am unable to get a complete valid path this way.

        I get "." for /root and its immediate children. I get relative paths for nodes deeper in the tree.

        It works the same way in 4.2.

        The failure of Copy Node Path to provide the correct, full path looks like a bug, but it's a feature I rarely use.

        • xyz replied to this.

          DaveTheCoder It returns relative path from scene's top node. It's probably done that way to keep it consistent with the "local" tree where you don't get to see the root node so It may be confusing to return an absolute path containing it.

          Thanks for the input everyone. I guess there is no reason not to open an issue and see what devs wanna do about this.

          • xyz replied to this.

            Rpahut I don't see a reason to open it. But if you must - go ahead. Hope you'll post the link here so we can follow the discussion.

            5 months later

            Rpahut
            If it can make you feel better, I'm impressed that you didn't lose your cool after reading all the random arguments and all the answers that completely missed the point, as 90% of the time in the Godot ecosystem

              jeancallisti Hi there! I see you are new here, welcome! Just a reminder of our rules if you haven't read those already. Let's keep a good spirit and be helpful with constructive comments.