Hello everyone,
I’m starting this thread to discuss general approaches to design components and communication between components/game-objects. I know that this thread can go deep into off-topic territory. But still I need some help with following questions:
- How do you design components to be atomic? I’m really struggling with this and most of approaches described online have some kind of issues later in the project’s development.
Good example is singleton pattern. It’s really easy to start but refactoring becomes a nightmare.
Same goes for built-in service locator methods. It’s handy, it’s built-in but it assumes hierarchy of gameobjects. So if I use GetComponent I assume that needed component should be on the same GameObject which makes component coupled to hierarchy. Should I create some kind of connector component for specific prefab(e.g. player) to inject dependencies into multiple components using GetComponent/Find().GetComponent?
-How do you design dependency flow in your project? Is it dynamically spawned objects(players, monsters, etc.) depend on scene objects? Or scene objects search for dynamic objects(managers search for players, monsters, etc)? Or both types(static and dynamic) depend on scriptable objects?
-How do you test prefabs independently?
Frankly, I’m frustrated. I’ve been using unity3d for 7 years already and I’m still to find least painful method for dependency management, components design and communication. I know that there’s no such thing as silver bullet but I really hope that this community can help me to find next best thing.
EDIT:
Maybe there’re some simple rules like Godot’s “Call down, signal up” that you’ve come up with?