Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Mechanim vs Legacy Animations

Discussion in 'General Discussion' started by jonmalave, Oct 31, 2013.

  1. zombiegorilla

    zombiegorilla

    Moderator

    Joined:
    May 8, 2012
    Posts:
    8,201
    Whoops, spoke too soon. I just checked on the status of the bug about the legacy animations controlling materials, and the response has been changed. Previously it just said that the Animator was a suggested solution. It now says:
    http://issuetracker.unity3d.com/issues/cant-animate-color-value-of-materials

    Sounds like its days are numbered. :(
     
  2. angrypenguin

    angrypenguin

    Joined:
    Dec 29, 2011
    Posts:
    13,053
    Can mecanim do everything that you can do with legacy animations? I thought there were still a few (admittedly niche) things that it still couldn't do?

    Mecanim is an excellent tool, but I agree that there are some use cases where it's not an advantage compared to the legacy system.
     
  3. ZJP

    ZJP

    Joined:
    Jan 22, 2010
    Posts:
    2,646
    What about this?...
     
  4. im

    im

    Joined:
    Jan 17, 2013
    Posts:
    1,393
    i just noticed too, did any try it? does it work? is it worth it?
     
  5. AndrewGrayGames

    AndrewGrayGames

    Joined:
    Nov 19, 2009
    Posts:
    3,823
    Actually at present I still use neither - for the kind of spritework I do, legacy Animations can't handle it, and when I started my last main project, Mecanim couldn't either. I wrote my own animation system that handles both sprites and hitboxes.

    I have heard that Mecanim was expanded at some point to be able to animate sprites, so I'm investigating usages of it. Does anyone have some good reference materials, or experience with it they'd like to share?
     
    GarBenjamin likes this.
  6. TylerPerry

    TylerPerry

    Joined:
    May 29, 2011
    Posts:
    5,577
    Are you talking about Unity's sprites, if so, Mechanim could always animate them? and you should be able to do hitboxes as well.
     
  7. ippdev

    ippdev

    Joined:
    Feb 7, 2010
    Posts:
    3,021
    If you handle Mecanim as a switchboard with a number of booleans switches of which only one can be flipped on at a time it is easy to control it. I wrote a martial arts stance to stance controller with nine directions (eight directionals and one centered stance), three levels of each stance in substate machine and nine shuffles to execute if already in a stance and that key combo was pressed again. Each stance was capable of transitioning to any other stance as well as a full blow navigation controller. It was all controlled by ten booleans and a few floats. The script to do so in legacy would have been five feet long. The state machine has been called a beast but I believe it was easy to set up with proper transitioning down to the subframe blending level whereas in the legacy mode I had to hope .3 seconds was a good blend timing.
     
  8. AndrewGrayGames

    AndrewGrayGames

    Joined:
    Nov 19, 2009
    Posts:
    3,823
    Interesting...I never knew that.
     
  9. ZJP

    ZJP

    Joined:
    Jan 22, 2010
    Posts:
    2,646
    I will give it a try and back here with more informations.
     
  10. im

    im

    Joined:
    Jan 17, 2013
    Posts:
    1,393
    thanks :)

    here watch this video
    www.youtube.com/watch?v=iPlM1-3mEU8&feature=youtu.be

    looks like it works so i bought copy will try it out sometime this weekend and let you'all know... cheers!
     
    Last edited: May 31, 2014
  11. ZJP

    ZJP

    Joined:
    Jan 22, 2010
    Posts:
    2,646
  12. im

    im

    Joined:
    Jan 17, 2013
    Posts:
    1,393
    lol :)

    i tested with kyle robot and walking forward following the tutorial and it appears to work as advertised.

    i still need to do more testing with other characters and other animations from other sources

    but so far so good!

    in the meantime people should really consider taking a look at this asset, it could end up being one of the most important assets that has come out in a very long time and what unity should have provided in my opinion...
     
    Last edited: Jun 1, 2014
  13. resequenced

    resequenced

    Joined:
    Apr 17, 2014
    Posts:
    67
    Oh man - this is fantastic news! I'm picking this up tomorrow - THANK YOU guys for making the community aware of this asset.
     
  14. ZJP

    ZJP

    Joined:
    Jan 22, 2010
    Posts:
    2,646
    Yep. No particular troubles with my own tests. :cool:
     
  15. im

    im

    Joined:
    Jan 17, 2013
    Posts:
    1,393
  16. LeftyTwoGuns

    LeftyTwoGuns

    Joined:
    Jan 3, 2013
    Posts:
    144
    I WANT to use Mecanim but the Animator Controller simply does not work with parenting colliders to a rig's bones. Physics.raycast will go right through the colliders most of the time. Legacy animation doesn't have this problem. And I haven't found a single solution to it. I wouldn't imagine putting colliders on a Mecanim character would be such an abstract concept
     
  17. kanga

    kanga

    Joined:
    Mar 22, 2010
    Posts:
    225
    Add the collider to the character and it will work.
     
  18. lmbarns

    lmbarns

    Joined:
    Jul 14, 2011
    Posts:
    1,474
    Animation baker rocks. Also "physics to animation" is cool too.

    As a programmer I hate having to use a graphical UI to set up animations in order to start using them in code.

    One thing I use the legacy animation system for quite often is programmatically grab all the animationstates in the animation component, and use a template based on the objects type.

    Example: I have 20 animated characters I want to be fighters. Each character has 10+ animations. I can simply set the order of the animations in the array in the animation component on each prefab, keep track of the index of each, and in code can:
    • Dynamically grab all animation states on an object
    • Knowing the order of them, build my code to reference the correct index for each animation
    So on each of 20 characters, the first 5 animations might be: idle, walk, run, jump, attack1. I can drop the same script on all 20 and they'll behave the way they're coded with no configuration, I can even change the speed, wrapmode, etc at will.


    So how can you do the same in mecanim without having to configure the model and map all the animations to variables, without having to use a graphical UI???
     
  19. LeftyTwoGuns

    LeftyTwoGuns

    Joined:
    Jan 3, 2013
    Posts:
    144
    The colliders are on the character. They were created with the Unity ragdoll wizard, parented to the bones. Animate Physics is also checked, which as far as I can tell from my experiences, doesn't ever do anything at all for Mecanim characters
     
  20. ippdev

    ippdev

    Joined:
    Feb 7, 2010
    Posts:
    3,021
    I manually applied colliders to rig joints for damage control and they worked. If you are trying to rag doll then you need to use workarounds like a replacement rig for the ragdoll effect.
     
  21. LeftyTwoGuns

    LeftyTwoGuns

    Joined:
    Jan 3, 2013
    Posts:
    144
    Well, I just did that with a brand new character, added a collider and rigidbody to their forearm bone, and the raycast hits every time, using the same animation as the other characters and a Animator Controller. So now I'm really confused. Do you have any idea why it would vary from one character to another?
     
  22. ippdev

    ippdev

    Joined:
    Feb 7, 2010
    Posts:
    3,021
    Don't know. Last night I changed an operation from * to + and for the next four tests it still gave the wrong number. I gave up and wrote something else and tested and it worked. Perhaps meta data not getting reset till save or other causes an internal recompile of meta data??
     
  23. ZJP

    ZJP

    Joined:
    Jan 22, 2010
    Posts:
    2,646
    This... :p
     
unityunity