Short introduction: I started learning Godot by making simple existing games. I made a Flappy Bird clone and it was ugly, but worked. I knew it could be a lot better, so I looked up a (pretty excellent) tutorial on Youtube and got the reference project through the Godot library. It's an excellent Flappy Bird clone, but the teacher loses me a bit when getting nodes.
In the tutorial you access a method on a camera2D node in the main tree, from a Scene which isn't on the main tree. To get this to work, he uses a clever utilities node, but the code comes down to this:
onready var camera = get_tree().get_root().get_child(get_tree().get_root().get_child_count()-1).get_node("Camera2D")
I've tried many other ways, but failed. I tried to look up a better solution on here and in the official documentation, but didn't find any. I also think this may not be best practise in light of decoupling...But maybe I don't fully understand this as I'm still a novice/intermediate programmer.
Anyway: can anyone point me in the right direction to fully understand this and provide an example of how the above code could work, but in a less roundabout/best practise way?