|Topic was automatically imported from the old Question2Answer platform.
This is a very simple question. I want to organize my projects better. With projects that aren’t games, for example in Eclipse or other IDEs, I have an easier time, but with games in godot I feel like I’m just throwing nodes and instances of scenes into a cauldron to see what comes out.
I’ve seen tutorials about how to organize the files to make them more easily shared via git, or how to organize nodes in each character’s scene, but although those tutorials are really useful, they aren’t what I was looking for.
What I want is to know how you organize your controls, GUI and character scenes.
In my game, there are different “maps” or “biomes”, and each of them can be populated by multiple characters, as well as the player. I also obviously have a GUI, and I also have a script which encapsulates all the code pertaining controls and how the player moves and interacts with the GUI. Things like “I” opens the inventory, etc.
In the end what I end up doing is I create a map scene, I instance the player and a few monsters, I also throw a GUI scene inside the map scene, and for some reason I can’t explain one of the GUI scenes is instanced inside the player scene. This needs to stop, this is currently a prototype with very little to no content and functionality, but I refuse to continue without organizing my project better.
Where should I attach the script with all the controls? Should I even attach it to an instance of the player or something?
Where should I place the instances of GUIs, like inventory, crafting and health bars?
Should GUIs be instanced inside each and every map?
If there is some project somewhere that I can look at for inspiration, I would be super grateful
I wasn’t able to find this specific information on the internet. It wouldn’t be the first time I couldn’t find it because of my incompetence, but please, if you’d like, could you share how you organize your games?
I’m just starting to use godot to make actual games. Before it was just simple programs to visualize mathematical concepts like fractals.
Thanks in advance!!
I dont have the time to give a full answer (which would be a bit subjective anyways), but:
and for some reason I can’t explain one of the GUI scenes is instanced inside the player scene.
I can see two reasons you would be doing that (might not be your case but I’m guessing here):
You want the GUI to “follow” the camera (which I suppose is also under the player?) Solution: unless you are doing health bars in world space or something, use a CanvasLayer. Many beginners do this “mistake” but CanvasLayer is a lot cleaner so the GUI can be separated.
You want to communicate states from your player to the GUI and vice versa. This is a bit more complicated but the way I deal with this is through injection. The player and the GUI dont know each other, but there must be a node parent to both which knows them / loads them in. In which case, this node can call a
gui.set_player(player)function for example, so the GUI can be told to synchronize with the given player for example. This can also be achieved by wiring a NodePath property in editor if you prefer.
Zylann | 2022-03-16 14:04
Thank you for your reply!
I would like this GUI element to stay on the same location on the screen, not affected by the movement of the camera. And no, it’s not related to the character. It’s a health bar that displays the name and health of monsters. For some reason I put it under player. I must have done that in a drunken stupor or else I can’t explain this.
I will try to draw different ways to structure my project on paper before trying to fix this mess. I refuse to continue with the project before this mess is untangled and tidied up.
C:\Flavius | 2022-03-16 21:47