Hey, i have a fair bit of experience with unreal and unity and i’ve been messing around a bit with godot.
I have a bit of experience with python but far less than i do with C++ and C#.
In general, the more i can handle things from code, with as few strings to identify what i want to do and with as few manual connections done from the scene, the better i’d consider a solution to be.
I’m having a bit of a hard time wrapping my head around how to deal with the “1 node = 1 script” choice and i’d love to hear some thoughts.
Ok so, the problem:
In unity/unreal i can have for example a “spin” script, a “levitate” script, a “health” script and a “collider” script.
They respectively make the object spin constantly, levitate up and down, it can be damaged and it has a collider.
The first two scripts would just get the object’s transform and interact with the position and rotation.
Add all together, i now have a little flying enemy.
All is well, my “bullet” can, on collision, get the health script and if present it can deal damage to my enemy.
If i want i can make a “crate” by only having the health and collider scripts, or a “pickup” with just the levitate and collider scripts.
However, in godot i can’t have a node with all those scripts, instead my “flying enemy” node will have 4 nodes, each with 1 of those scripts.
I’m inclined to leave the top node (“flying enemy”, “crate” and “pickup”) without any script as a result.
This means my top node is just used for the transform, allowing me to add and remove components without messing anything up.
(quick side note: it’s unfortunate that i need a child node, thus a transform, for each script… I don’t need the position or scale of the health node for example)
The spin and levitate scripts have to take a reference to a transform, as they now have to affect the parent. Reasonable.
However it’s more complicated with my health and collider scripts, as i’ll be colliding with the latter, but i want to have the former take damage.
I could give the colliders a reference to the health script, but that doesn’t seem very good as there’s no reason for the collider to have the concept of health and damage.
Or i can operate under the assumption that everything is structured in the same way (empty parent, all components as child of it) and have the bullet script get the collider’s parent, and from it check if there’s a health script.
But it seems a bit stinky and error prone, it also means i can’t have colliders parented to each other as then the parent isn’t what i’d expect (eg: a character’s arm may want multiple colliders).
There is .owner, which gives me the root of the “local” scene (so the “flying enemy” and the “crate”), that may be useful here as it can replace using the parent (as long as i can set the owner if needed, in case i’m instantiating nodes at runtime).
I get the owner’s health script, make it take damage and it’ll handle the damage calculations.
In short the question is: what is “the godot way” to approach this kind of architecture?