Trying to recreate some Unity programming patterns in Godot, would appreciate some pointers!
Hello everyone!
I've been a game designer for a good amount of years now, and I've recently started to make the shift from Unity to Godot for making some personal projects. The thing is, I'm not a traditionally trained programmer. All of my programming abilities in Unity I've figured out via testing various patterns and finding what works best for me. Because of that, though, I don't know the technical names of a lot of programming patterns, so I'm unsure of what I should be searching to figure out how to find the same workflow in GD script.
I really enjoy making systems super modular to ease creating things within the engine window itself, and to that end I normally do two things:
* I liked to have a lot of objects call the same event for a single object to grab. The best example usecase for this is something like a universal "inspection text" system: I could have a single component to put on any object that says "if the player hits E on me, send an event to display this text in the dialogue box". These objects wouldn't pick up on if the dialogue box was even in the scene, they would just send the event with the data needed. That way, I could easily make a ton of objects the player could interact with in any given scene, but said objects wouldn't have to mess around with finding references to the dialogue box, and said events could also be easily ignored if the dialogue box wasn't in the scene for whatever reason. I've played around with signals and got a few demo things working with them, but signals seem much more suited to having one node communicate with a bunch of others at the same time, rather than a bunch of nodes sending out messages to be received by a single one. Having a ton of nodes in a scene finding a single one via get\_node seems inefficient, but having something like a singleton to hold a reference to a single important node seems a bit overkill. * I used public UnityEvents a lot, as they allowed you to call a specific single public method on any component specified in the inspector. This was mostly useful for easily configuring complex actions without needing any scripting: I could slap a player detection component onto an object, and said component would just have the code to say "when the player enters this box, perform an action". Then, I could go to the inspector, and click and drag any other object into the field in the inspector, and assign any public function to be that action that gets performed. I could even turn these into arrays to be iterated through, to assign multiple functions to a single trigger: "When the player enters this box, switch to this camera, and also display this dialogue". It was a very powerful way to slot together complex interactions like puzzle pieces.
I mostly just need to know what the expected Godot equivalents to these things are, as once I know the names of what I'm supposed to be searching for, I can read a lot of the documentation myself. I just don't know a lot of the more technical terms for these types of behaviors by name. I've made some progress with researching the second bullet point so it's less pertinent than the first, but I've also seen *multiple* answers to it, so an up-to-date consensus would be helpful. Any help would be appreciated!
EDIT: Okay, this was mostly solved! I have a preload going to give me global access to a signal, which lets me do the "many nodes signaling to one specific node" functionality I was looking for. It also seems like the best solution for direct arbitrary function to function calls is to also just connect signals within the signal window, which isn't the greatest because there's a lot of left clicking and a whole dialogue popup to contend with, but I can see how the intended usecases now. Thanks for the responses everyone!