I’d like an insight or opinion about how to implement a good component based system.
Example: Whenever a GameObject gets a Rigidbody Component attached, the transform gets automagically altered when running the game due to PhysX.
From what I understand is that Unity checks all GameObjects for their components and plugs them into it systems.
Now my question is how I would go about doing the same thing with custom components?
Let’s say I create a component that makes a GameObject touchable (adds a boxcollider2D too). I don’t want every GameObject to run an overlapPoint on itself to see if it was touched. I’d rather run that once and the object found accordingly, let’s call that class InputManager. This already means I have to write a component and a system that works it.
How do you guys setup the necessary system? does every component register itself to the InputManager, where that instantiates itself on the first call (singleton)? Or do I keep an InputManager System on a GameObject in the scene which searches the whole scene in the beginning? Or just check the touched GameObject if there’s the corresponding component available and call stuff on it? Do I need to do that for every component, write an outside system? I mean, this is how Unity works, right?