Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Mecanim Additive Animations

Discussion in 'Animation' started by MrScary, Feb 4, 2014.

  1. MrScary

    MrScary

    Joined:
    Dec 8, 2007
    Posts:
    94
    Is there some special trick for creating additive animations for mecanim?

    I have two layers.. one that has additive animations for shooting and one that does additive animations for looking up, and looking down. They both use an avatar mask although the masks are slightly different. The look anims include the head in the avatar mask.

    The shooting additive works great. The look anims don't do anything. The differences are that the look anims are about 2 frames long where the shooting anims are longer. And the transitions for the shooting animations go to motions, whereas the transitions for the look up/down animations go to a blend tree with a float parameter blending between look up and look down.

    Can't figure out what's going on. The shooting layer is after the look layer and I even set the blend weight for the shooting layer to 0.0 and still see nothing.

    thanks.. andrew
     
    Last edited: Feb 4, 2014
  2. pierrepaul

    pierrepaul

    Unity Technologies

    Joined:
    Jun 19, 2012
    Posts:
    162
    Hi.

    The way that additive animations currently work in Mecanim is that they use the 1st frame of the animation as a "reference" and make the rest of the animation relative to that pose.

    Since you have no animation in the LookAt, we don't have anything to extract "additive" animation out of it.

    In the future we want to add the ability to set a "reference" pose that is different from the 1st frame of the animation. (the frame could be specified from a different animation source).

    Until then, I would say that the best way to do LookAt in Mecanim is to use our own LookAt API:

    http://docs.unity3d.com/Documentation/ScriptReference/Animator.SetLookAtPosition.html

    and

    http://docs.unity3d.com/Documentation/ScriptReference/Animator.SetLookAtWeight.html

    a usage example is here :

    http://u3d.as/content/unity-technologies/mecanim-gdc2013-sample-project/4Zj
     
    Vashchuk likes this.
  3. MrScary

    MrScary

    Joined:
    Dec 8, 2007
    Posts:
    94
    Hi Pierre

    Thanks for the information and taking a look at that. A couple quick questions. If we used a two frame animation, the first frame being the reference pose and the second frame being the "look up pose", would that work? or do we need to include a full animation going from reference position to "look up"


    Regarding LookAt in mecanim.. I have played with that and it's very nice. Performance wise, is that as efficient as an additive animation and is it okay to use on iOS?


    Thanks again
    Andrew
     
  4. pierrepaul

    pierrepaul

    Unity Technologies

    Joined:
    Jun 19, 2012
    Posts:
    162
    Hi!

    You need to include the full animation BUT something that can be tried is to force with script the state to always stay in the 2nd frame.

    Animator.Play( stateName, layerIndex, 0.5f);

    Its a bit hackish, but that might just work. Keep me posted!

    Our ik engine is fairly efficient, and I would expect it not the be more costly than an animation layer. Be sure to active IK Pass on the layer where you want to apply it! Keep me posted on this aswell if you try it!

    cheers.

    [[
     
  5. MrScary

    MrScary

    Joined:
    Dec 8, 2007
    Posts:
    94
    Thank you for the info! Will give it a try and report back.

    Regards,
    Andrew
     
  6. z00n

    z00n

    Joined:
    Nov 24, 2009
    Posts:
    44
    Is any ETA for this "reference" pose thing available? Thanks in advance.
     
  7. pierrepaul

    pierrepaul

    Unity Technologies

    Joined:
    Jun 19, 2012
    Posts:
    162
    Hi. We haven't started working on this yet.

    I won't be in 4.x release cycle, buy hopefully in early 5.x
     
  8. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Any ETA on Generic IK? we are very much looking forward to it here so that the player can grab items and pull him/herself up when climbing :)
     
    theANMATOR2b likes this.
  9. Mecanim-Dev

    Mecanim-Dev

    Joined:
    Nov 26, 2012
    Posts:
    1,675
    I can tell you that it won't be in 5.0, we would like to ship it in 5.1 but this is still a work in progress so there is no guarantee that it will be in 5.1
     
    hippocoder likes this.
  10. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Thank you, it's fine! I appreciate all your hard work.
     
  11. ColinKnueppel

    ColinKnueppel

    Joined:
    Nov 6, 2013
    Posts:
    9
    Is this also eta'ed into 5.1 or sooner?
    It's hard to describe how much work this would save us. I'll see if I can get the hacky version working, but still.. when will this happen!?
     
  12. Nanako

    Nanako

    Joined:
    Sep 24, 2014
    Posts:
    1,047
    @Mecanim.Dev @pierrepaul is there any progress or ETA on this feature yet?

    I want to add my voice (and my two other teammembers) to those requesting this. Additive animations are utterly critical to our current project, we have to use them, with or without this feature. But without it, we're having to use some messy and unreliable kludges that look bad, and cause a twitch at the start of every loop from the reference pose in there
     
  13. Mecanim-Dev

    Mecanim-Dev

    Joined:
    Nov 26, 2012
    Posts:
    1,675
    No work have begin for this yet, but it still on our short term road map as one of the most important missing feature.
     
    Nanako likes this.
  14. U-GeeN

    U-GeeN

    Joined:
    Mar 22, 2015
    Posts:
    95
    Hi,
    I'm also stuck with the additive animations.
    So I have multiple animation layers. One overrides and others are additive.
    Furthermore my Animations consist of only one key and are interpolated in oneanother throug 2D blend trees.
    I want each layer to control an animated object at once, additive like.
    But my objects move only if the layers are override.
    How do I create that reference point and is it possible to run override and additive layers simultaneously.
     
  15. Mecanim-Dev

    Mecanim-Dev

    Joined:
    Nov 26, 2012
    Posts:
    1,675
    You will have to wait for 5.3, we did implement the new additive layer with the reference pose in this version
     
  16. U-GeeN

    U-GeeN

    Joined:
    Mar 22, 2015
    Posts:
    95
    Ok, I'm on it and got my reference from a different clip.
    But a fundamental question: are additive Layers ment to exist along with override layers?
    Or should all layers be additive if additive animations are used?
    And some practical question:
    I'm using a dozen animations (or ending positions in my case).
    Their reference point has to be set at zero frame of one reference clip.
    How can I set the reference point for all animations in a StateMachine at once?
     
  17. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Hello! I'm interested in Additive animations but I'm still confused as to the purpose of additive animations. When and where should I be using them, and for what purpose?
     
  18. U-GeeN

    U-GeeN

    Joined:
    Mar 22, 2015
    Posts:
    95
    I use them to add a battlestanza to a moving animation.
    The movement layer rotates the body and legs.
    And the fighting layer adds rotation to the body and arms position.
    So the animations act undependantly and its possible to create all kind of variations without having to create a whole new animation.
    Was that understandable?
    And for my last question:
    Do the reference animation and the additive animation must have set same properties they change?
     
    Last edited: Dec 14, 2015
    theANMATOR2b likes this.
  19. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,670
    ^ I use them for similar purposes -- adding a crouch to walking to make a crouched walk, adding a slouch or a chest-out strut to change the character's personality, adding a hit reaction on top of whatever the character is doing, etc. I haven't tried Unity 5.3's new additive animation changes, but as long as I follow the rules pierrepaul described above additive animation works great.
     
    theANMATOR2b likes this.
  20. U-GeeN

    U-GeeN

    Joined:
    Mar 22, 2015
    Posts:
    95
    Now I got my stuff to work.
    Only problem is that some animations add more rotation that they should have.
    Seems like they add y rotation of the reference frame to the relative y rotation.
    And another question:
    Does the reference animation have to be present in the animator?
    Or is it possible to reference any animation in the assets?
     
  21. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,670
    I haven't tested additive in 5.3, but at least in previous versions the additive rotations are applied based on their difference from the first frame of the same animation clip.
     
  22. U-GeeN

    U-GeeN

    Joined:
    Mar 22, 2015
    Posts:
    95
    My additive animations calculate infinite values for my rotations.
    Anyone suggestions why this happens?
    And I can't add properties to a animation via the "add property" button in the animation window.
     
  23. U-GeeN

    U-GeeN

    Joined:
    Mar 22, 2015
    Posts:
    95
    I just noticed something.
    When I create new additive animations with only one rotation property it plays correctly.
    As soon as I add more properties the relative rotation calculation messes up and I get NAN as value.
    Am I doing something wrong?
    Has anybody an additive animation tutorial for me?
     
  24. yabea

    yabea

    Joined:
    Feb 26, 2015
    Posts:
    6
    @U-GeeN Seems like the issue has been fixed in Unity 5.3.3f1:
    I've found 2 bugs in the issue tracker and one of them matches perfectly with what happens in our project. I downloaded 5.3.3f1 and it fixed the issue. Maybe it'll fix yours, too?

    https://issuetracker.unity3d.com/is...-to-nan-when-it-includes-a-rotation-component
    https://issuetracker.unity3d.com/issues/rotation-of-ui-element-makes-it-not-show-on-android-device
     
    theANMATOR2b likes this.
  25. U-GeeN

    U-GeeN

    Joined:
    Mar 22, 2015
    Posts:
    95
    THX I'll try that out
     
  26. Malbers

    Malbers

    Joined:
    Aug 7, 2015
    Posts:
    2,558
    AMAZING, Stuff With the Additive Reference Pose on 5.3, I was searching for that for a looooong time, lov you unity guys, save me a lot of troubles