![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | zeitgeist |
Hi, just getting started with Godot.
I saw the posts from KidsCanCode:
http://kidscancode.org/godot_recipes/basics/getting_nodes/
http://kidscancode.org/godot_recipes/basics/node_communication/
And understand that the best way to pass variables down the tree would be directly through node reference and up the tree would be through signals.
But I am building a scene and want to understand the best practice to understand how to work from now on either by passing variables through a specific way or changing my scene construction.
So I have a main Scene.
This Main Scene instantiate a player scene and one or more enemy scenes.
It also instantiates a Score scene (where later on I will build the UI elements).
The players or enemies instantiate bullets scenes. So after all instantiations, at one time I might end up with something like this:
Main Scene:
|-Player
-----Bullet 1
|-Enemy 2
-----Bullet 2.1
-----Bullet 2.2
|-Enemy 3
-----Bullet 3.1
|-Enemy 4
-----Bullet 4.1
-----Bullet 4.2
-----Bullet 4.3
|-Score
The Main Scene script handles score counting and sending to Score scene, AI movements and shots.
The Player Scene handles player movement and shots
Score Scene only has the labels, so far. I was building it as to only handle the visual part of the UI, and not have any scripts.
The Bullet scene handles collision and needs to send collision info and points for score update up until the Main Scene
The Main Scene will then calculate the new score and pass it down to the Score Scene to update it visually.
Problem is that passing the collision update and score up the tree thorugh node reference would not be a good idea, as the article mentioned as any change would break everything.
But to send a signal, if I understand correctly the right way would be to have only a “connector” in the Main Scene and that Main Scene pass down the score update to a function inside the Score Scene. But since my Score Scene does not handle scripts I would need to change the way it works to accomodate this.
SOOOOO
Question 1. Should I be using emitters in this case? And if so I will then need to attach a script to the Score Scene right?
Question 2. Is the way I am building the whole scene the right way or should I be going about it differently and that is why I am having problems?
Thanks