Search Unity

What's the difference between animation and animator?

Discussion in 'Animation' started by Modest.Blue, Jan 4, 2015.

  1. Modest.Blue

    Modest.Blue

    Joined:
    Dec 25, 2014
    Posts:
    4
    I'm new in Unity and doing some self-learning.
    When I was having fun with the animations using a single cube. I found that both the animation and animator components can animate the transform properties. But when it comes to material, it seems that only the animator can accomplish the material change such as the mateiral._color.a. Changing material values in animation clip just don't work.
    Well, I may have a problem presenting my issue. I uploaded a simple project displaying my question. In the project, scene test1 uses animator while test2 using animaiton.
    Best regards and Happy New Year.
     

    Attached Files:

    DragonCoder likes this.
  2. Mecanim-Dev

    Mecanim-Dev

    Joined:
    Nov 26, 2012
    Posts:
    1,675
    The animation component is the legacy animation system which was not updated since 4.0, it doesn't support new feature like Sprite animation or material properties animation. In those case you have to use the new Animator Component.
     
    TillinElohim likes this.
  3. ChanMOOOOR

    ChanMOOOOR

    Joined:
    May 7, 2014
    Posts:
    10
    Well , I need to know how to create Sprite AnimationClips during runtime which can be used by the animator.
    In the "Legacy" animation ,there is a way to create and add AnimationClip dynamic for the Animation component. However,Mecanim only could Override the Slot already in the animator controller, what make matter worse, i can not get the all animation clip informations, only can GetCurrentStateInfo,you know what i mean ,it's inconvenience. i'd like to bind some animation events for the animations in the animator controller.Now the only way to do this is produce a new AnimatorOverrideController and override old one . oh my god!!!!!!!!huge circle isn't it ?
    and more ,i need to create sprite Animation during runtime ,what should i do ? where is the property name like"localPosition.x" in the AnimationCurve?:oops::oops::(
    Those questions make me annoy.
     
  4. Umair Jameel

    Umair Jameel

    Joined:
    Jan 8, 2015
    Posts:
    1
    You need to create Animation and apply this animation to your object, what You need to do is to disable the animator for that object and enable that animation at run time using script, like obj.enable=true;
     
  5. Mecanim-Dev

    Mecanim-Dev

    Joined:
    Nov 26, 2012
    Posts:
    1,675
    Hi ChanMOOOOR,

    You cannot create a Sprite animation curve at runtime.

    In 5.0 we did add a new member to RuntimeAnimatorController class

    RuntimeAnimatorController.animationClips return all the clips from the controller.

    Best regards,
     
    ChanMOOOOR likes this.
  6. ChanMOOOOR

    ChanMOOOOR

    Joined:
    May 7, 2014
    Posts:
    10
    After learn more about Sprite animation i can understand why there is no way to create Sprite animation curve at runtime now. Thank you for your reply. before 5.0 i still can access the animationclips by RuntimeAnimatorController, however it will be more steps to do the same thing;)
     
  7. Leggy7

    Leggy7

    Joined:
    Feb 18, 2014
    Posts:
    21
    How can You exactly access animation clips via RuntimeANimatorController? I'm looking into it but cannot figure it out.

    Just saw that it is available in unity 5. Still on 4.5 :p
     
    Last edited: Apr 21, 2015
  8. ChanMOOOOR

    ChanMOOOOR

    Joined:
    May 7, 2014
    Posts:
    10
    Hi there , the RuntimeAnimatorController looks like a jar which can put the same animation as the AnimatorController you already have .so things turned easy.

    animator = GetComponent<Animator>();

    you can get animator.runtimeAnimatorController THEN create an AnimatorOverrideController to recieve the informations ....from the override one you can get the source AnimationClips. the more detail should found in the Unity Script documents