- Home /
Question by
NightyNightYT · Oct 22, 2019 at 08:53 PM ·
componentinterface
Inheritance vs Composition
When should I use components instead of interfaces?
For example, my interaction system is currently using interfaces (so Door will implement IInteractable) so that I can have different implementations for different objects since I don't want every interactable to do the exact same thing (which is what would happen if I made Interactable into a component).
So when should I use one or the other, and would it be possible for components to have separate functionality on each object they are placed on? For instance, the interactable component on a door would open the door when OnInteract() was called, but the same component on a weapon pickup would add the weapon to your inventory when OnInteract() was called.
Comment