Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

How to handle tons of animations in mecanim :[

Discussion in 'Animation' started by ahdros, Aug 10, 2016.

  1. ahdros

    ahdros

    Joined:
    Aug 3, 2015
    Posts:
    5
    Hello to all!

    And for a start I want to say that I’m not a native English speaker, so... sorry for the grammar mistakes :)

    here is the story:

    I have a character with a lot of different animations: animation for movement, crawling, climbing ledges/ladders, and even animation for different world interactions (aka open doors, use levers/ valves etc.) and on top of that, I have a somewhat big set of weapon types, and every weapon type have to use its own set of animations.

    My character controller already have Action query which controls character’s behavior, so I see no point to create another FSM in mecanim system only to struggle with synchronization of two FSMs afterwards. So, right now I decided NOT to use mecanim’s state transitions, and do all animation transitions through "animator.Crossfade" and "animator.Play".

    here the questions:

    1. If my animations will be in mecanim sub-state machines, will I be able to crossfade to animations in this sub-state machines and how? (I would’ve checked myself, but I will have no access to Unity another couple of days)

    2. Maybe there are better approach to solve this animation management problem in Unity? Or at least some advises?
     
  2. Mecanim-Dev

    Mecanim-Dev

    Unity Technologies

    Joined:
    Nov 26, 2012
    Posts:
    1,675
    As long as all your state are all in the same layer you can use Play/CrossFade to transition to any state.
    I would suggest you to use the fixedTime version because the other one work in normalize time.
    http://docs.unity3d.com/ScriptReference/Animator.CrossFadeInFixedTime.html
    http://docs.unity3d.com/ScriptReference/Animator.PlayInFixedTime.html

    For this I would use an AnimatorOverrideController
    http://docs.unity3d.com/ScriptReference/AnimatorOverrideController.html
    Simply override the animation clip for the weapon and change it when the user swap weapon.

    If your game only have one character type(all your charactrer in game share the same transform hierarchy) and you don't want to use IK you should use the generic rather than the Humanoid rig, there is a performance cost when you use the humanoid rig for the retargeting and IK pass.

    There is another option, you can use the Animation component aka legacy
    http://docs.unity3d.com/ScriptReference/Animation.Play.html
    http://docs.unity3d.com/ScriptReference/Animation.CrossFade.html

    In this case switch the weapon animation clip when needed
    http://docs.unity3d.com/ScriptReference/Animation.RemoveClip.html
    http://docs.unity3d.com/ScriptReference/Animation.AddClip.html
     
  3. ahdros

    ahdros

    Joined:
    Aug 3, 2015
    Posts:
    5
    ok, got it. Thanks for the tips ^-^