Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | JulioYagami |
I need to know this to better work with the get_node
function and write the proper path strings to use with $. I want to know something like this:
- Scene Tree
- Main Scene
- Node1
- Node2
I notice Godot works a lot like the old game engines, and I have started mimicking there tree designs.
So it looks something like this for me:
Main #This node is responsible for Global values, like score
--MainMenu #Keeps all my menus
----Options
----FileBrowser
----Inventory
--LevelAssigner #This node changes the current "level"
----Level4 #Levels that aren't used is removed completely, freeing resources
------Light
------Floor
------Enemy
------Pickup
----Player #Player is actually next to level, to keep it persistent when level changes.
If you keep the tree flat, it becomes difficult to find things. The nodes like MainMenu and LevelAssigner acts as groups. If I want a menu I know where to check.
MysteryGM | 2018-12-07 22:47
That was not quite what I wanted to know. I want to know how I can get a node from the scene tree, for example in this code:
get_tree().get_root()
For example, how can I get the “Inventory” node from the scene tree?
JulioYagami | 2018-12-08 09:53
Do you think this get_tree().root.get_node("NondeName")
? Your question is not clear enough.
pospathos | 2018-12-08 12:38
$MainMenu/Inventory is not working for you? I’m not sure if i understand the problem
p7f | 2018-12-08 12:40