This might not be a question specific to Unity since it can be more related to a OOP or separation of concerns doubt, but still wanted to know if anyone has faced a situation like this. It probably doesn’t have right or wrong answer either.
My scenario is the following:
-
I have a player prefab which has an animator component and a script attached to it that handles the different transitions for the animator (sets parameters, triggers animation, etc.).
-
The player has skills (like in a Diablo-like game). A skill can be a complex attack which can involve several animations, or events within the same animation. Each of those animations or events can perform different kinds of attack. eg: the first movement does one type of damage and affects some of the player stats, the second attack movement does a different damage and can affect other stats, and so on. So, in essence, each skill can be a compound of abilities, where each ability does a different thing.
Now, the question here is which approach is better, in terms of performance and scalability:
-
to have all the player’s animations (including the skills animations) in one single, God-like animator component associated to the player prefab (maybe with each skill in a different layer)? The player’s controller class will have to call the skill/abilities methods in the Skill class, to actually apply the damage or modify the stat or whatever, whenever an attack skill animation is triggered.
-
to have one animator component for the player for the base animations (idle, walk, run) and one animator per Skill prefab. The advantage of this is better separation of concerns, so that the skill doesn’t have to know anything about the main animator and viceversa. But, I’m not entirely sure about how this could scale or perform, when having dozens of skills (and dozens of animators).
Suggestions?
Thanks.

