How paths really work?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By GunPoint
:warning: Old Version Published before Godot 3 was released.

Okay, so i couldn’t understand how paths work
I know how the scenetree, root etc work but i can t understand why my game can’t find given paths
My questions:

  1. How to acces a node that is not a child and it is in the current scene
    • player
    • items
      How i can get the node “items” in the player’s script?
  1. How to acces a node that is not in the current scene and cant work with signals and singletons
    Example: Scenes: world, player
    how i can acces a node (inside player scene) while im in a script inside world scene
    For example, when the player hits something (in world scene), his camera (which is inside player scene) changes perspective ( in the case you can’t use signals or singletons) How i can get the camera node (which is in player scene) from a script which is inside the world scene
:bust_in_silhouette: Reply From: bruteforce


    • player
    • items
      How i can get the node “items” in the player’s script?

In your example the “items” and the “player” nodes are children of the “node” node.
Your script is attched to the “player”, so you have to move up one level to the “node” and you can get it’s child “items” node:




(IMO this method also works with instanced scenes)

Is this get_node() method case sensitive? Because i get errors like
“Node not found …”
Even when i write them letter with letter, this error shows up

GunPoint | 2017-11-07 20:11

Yes, the names are case sensitive.

bruteforce | 2017-11-07 21:10

This doesn’t work for instanced scene
I think u misunderstood my question
Here’s an example
The world scene contains

  • -player(instanced scene)
    • items

The player scene contains

    • sprite
    • collisionshape
    • camera

For example, i want to get the sprite node inside a world’s script
How i can do this?

GunPoint | 2017-11-08 14:34

Where is this script exactly ( “node” or “items”)?

If this “world’s script” is attached to the “node”, then:


But if it is attached to the “items”, then:


Or a more “universal” solution (it should work in both cases in the world scene):


bruteforce | 2017-11-08 17:40

How i can get a function from a different script?
For example, i want to call the move function i created inside game’s script
This doesn’t work : get_node('Player').move

GunPoint | 2017-11-10 12:53