0 votes

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?

2) 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

in Engine by (403 points)

1 Answer

+1 vote
Best answer

- - 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)

by (674 points)
selected by

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

Yes, the names are case sensitive.

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?

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


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

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.