For example, a character has 10 skills, and each skill has its own animation. I want to just create one state “Attack”, and play different animation based on different skill.
By using Mecanim, one “Animation State” has only one motion. If I want to implement above logic, I need to create 10 Attack States, each one contains a specific motion for each skill.
Is there any other way to implement it? Or, what’s the best way to implement such logic?
(This one you already described.) Add 10 different attack states. Transition from idle to the appropriate state based on an int parameter. My suggestion here is to put the 10 attack states inside a sub-state machine called “Attack”. Then, from a higher level, it will look like one transition into “Attack”, rather than a messy web of 10 different transition arrows.
Use a single blend tree based on a float parameter. Add all 10 skills as motion fields. Set the float to 0 to play the first skill, 1 to play the second skill, etc.
Use Animator.Play() or Animator.CrossFade() to manually go to a skill state. Personally, this is my least favorite suggestion, since it chops up the logic between the state graph and script(s).