Player's God animator vs separate animators?
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 character 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 the animator and character controller doesn't have to know anything about the skill. But, I'm not entirely sure about how this could scale or perform, when having dozens of skills (and dozens of animators).
Suggestions?
Thanks.
Answer by theANMATOR2b · Apr 26, 2017 at 08:38 PM
Please don't take my advice as gospel.
My book knowledge says the best setup is to decouple all systems as much as possible so one 'thing' doesn't need to know about another 'thing'. The one thing just needs to receive a trigger/event/param/var/bool - etc etc to let it know to adjust something it controls. The other 'thing' is sending the message when something happens that triggers it to send the message. This other thing knows nothing of the one thing and vis-versa.
And since it sounds like your systems are VERY complex - I'd want to decouple as much as possible - SO - that would allow each 'thing' to be scaleable as much as possible.
You might consider researching some fighting game systems. Although it sounds like your working on a hack-slash type rpg - the animation system in fighting games are structured in a pretty unique way, which sounds conceptually similar to your concept.
You may also benefit from reading through the design thread within the Unity forum. Some great advice worth its weight in gold is hosted in there.
Your answer
Follow this Question
Related Questions
duplicate enemies animations wont work? 0 Answers
how to Restore corrupted Animator 0 Answers
My animations started acting weirdly 0 Answers
NEED HELP ANIMATING PLAYER MOVEMENT 0 Answers
Animation changes when marked as legacy 0 Answers