Inheritance vs Composition

It really depends on the use case.

My Character class is a MonoBehaviour and it only has CharacterParameters (default speed, attack, shoot, etc.) and CharacterStates (moving direction, is jumping, etc… and all of these are events). Every enemy and player is required to have this.

Player has PlayerBehaviourController (brain of the player) and extends Character. AI has AIBehaviourController and extends Character (brain of the ai). All other components (PhysicsController, AbilityController, ConsumableController, etc. cache Character (getComponent()) so that they do not have access to the character behaviour controller but only to state and parameters, which they only really need.

But, for example, Abilities use composite all the way (factory + strategy + google sheet integration for easier updates) because if I want to create ice bulle, it is very easy. It reaaaly depends on the situation.

Privacy & Terms