![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | chexmo |
I think the title is very descriptive…
I’m currently using only the .gd files because I learnt to do so in the tutorials I followed, but I think the idea of a scene that encapsulates its own script is at least interesting.
I can see some corner cases in both options, but I can’t tell which one is better when.
For example:
- If you use .gd files…
- Reusability. You can later use the same file in other scene that behaves the same way. Or even in a different project.
- Scripts keep available from external tools, maybe.
- File structure grows up to x2 faster.
- If you’d like to use the same script in two different scenes you may have to deal with different child-nodes maybe, and handle stuff of both scenes.
- Less OO design/architecture, IMHO. For instance, although you can inherit one script from other via GDScript, it feels forced compared to godot’s scene-inheritation feature.
- If you use embedded scripts…
- To tidy up the files structure seems easier.
- Scenes made this way are not only a compound of states, but entities with their own behaviours now… which for some reason I feel more semantic that attaching scripts here and there.
- You only can edit code properly from the godot editor, and even so IDK if godot text editor fully supports this feature nowadays.
- Too much info in a single place. Breaks the single-responsability principle.
So…
Tell me…
- What you think about this?
- How do you work scripts?
- Is there any rule-of-thumb to decide if a script should be embedded to the scene or should be a separate .gd file?
Thanks