Godot 2.1.4 can't find given paths!

: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.

I have a MAJOR problem
So, my project has more scenes : game, player, etc
When i want to get acces to something inside the player scene in game’s code i wanted to get the player scene
So i did get_node("root/Player")
But it says Node not found root/player
And this happens with normal nodes too (not only with scenes)
Is there any other way that i can get the node “Player” ??

My node structure: (in the game scene)
-game

  • -sprites
    -player

Nodes in the player scene:
-kinematicBody (its called Player)

    • sprite
    • camera2d
    • collisionshape2d

Show a screenshot of your (expanded) node structure!

bruteforce | 2017-11-05 12:52

I can’t show screenshots but i edited the question so you can see the node struct

GunPoint | 2017-11-05 14:15

Try putting a slash before root:

get_node("/root/Player")

Otherwise you could try this:

var root = get_tree().get_root()
root.get_node("Player")

DodoIta | 2017-11-05 15:05

also get_node(“…”) gives the root (or parent?), so get_node(“…/Player”) should also get you what you want. If the problem is actually with the get_node() function, you can always iterate through children with the get_children() function.

ohmi | 2017-11-05 15:11