Search Unity

  1. Unity 2019.1 is now released.
    Dismiss Notice

Additive animations not working

Discussion in 'Animation' started by silentneedle, Jul 31, 2016.

  1. silentneedle

    silentneedle

    Joined:
    Mar 14, 2013
    Posts:
    280
    Hey Guys,

    I'm currently trying to add additive animations to my character. I've two animations:

    1. Idle (Base Layer)
    2. Hold weapon (Additive layer)

    So from my understanding, as soon I set the weight of the additive layer to 1 the character should play the idle with the hold weapon animation, but instead my character still idles without holding the weapon.

    Is there any special trick to create additive animations?

    I'm using Unity 5.3.
     
  2. Kim-Nobre

    Kim-Nobre

    Joined:
    Jul 26, 2016
    Posts:
    8
    I'm not sure why exactly are you trying to use an "Additive" layer, I usually use an "Override" layer for that, have you tried it already?
     
  3. silentneedle

    silentneedle

    Joined:
    Mar 14, 2013
    Posts:
    280
    Override is working fine, but it doesn't look good when my character is running (the arms are too steady).
     
  4. Mecanim-Dev

    Mecanim-Dev

    Unity Technologies

    Joined:
    Nov 26, 2012
    Posts:
    1,633
    Hi silentneedle,

    How did you created your animation clip?

    Additive clip are kind special, if you import a clip to be used in a additive layer and doesn't setup the additive reference pose, the system will use the pose at frame 0 in your clip as the reference pose.

    There is two way to setup the additive reference pose, when you import your clip you can define a frame to be used as the reference pose
    http://docs.unity3d.com/Manual/class-AnimationClip.html
    or by script with
    http://docs.unity3d.com/ScriptReference/AnimationUtility.SetAdditiveReferencePose.html

    I guess in your case you have an animation that hold a gun that last 1 frame, so the system use the same frame as the reference frame and the animation to add, since there is no difference between frame 1 and 1 you don't see anything move
     
    the_game likes this.
  5. exerion

    exerion

    Joined:
    Jun 29, 2011
    Posts:
    54
    Hi Mecanim-Dev =D

    Why is the Additive Reference Pose Clip setting not easily accessible for clips created within Unity?

    If I hadn't found this thread I would have continued to think the additive feature in Mechanim was broken.

    For those struggling with this you can additionally set your editor to debug mode to expose the settings when you have an animation clip selected. Don't forget to set the Has Additive Reference Pose bool as well as setting the Additive Reference Pose Clip otherwise it wont work.
     
    5argon and kiyaha_jr like this.
  6. stuffkikker

    stuffkikker

    Joined:
    Apr 22, 2013
    Posts:
    11
    Trying to do exactly this; I have an animation (let's call it "happy", frames 40 to 64) that differs significantly from idle, both clips from a single asset, and have the pose frame for happy set to the first idle frame (and additive reference pose flagged on obviously).
    Unity would have to take happy and substract that idle pose to get the additive difference, right?
    And if if I then play happy as additive onto idle, I should get my full happy animation, right?

    But it doesn't; it seems to just take the first frame of happy as a reference pose, and creates an additive clip based purely on that pose (which is some minimal jitter currently) that gets added onto my idle.
    I would say the result is quite sad instead...
    Am I missing something here?
     
  7. stuffkikker

    stuffkikker

    Joined:
    Apr 22, 2013
    Posts:
    11
    Actually, exerions tip for using debug mode revealed the issue; regardless of what frame is set as a reference pose, the importer will make use of a 'preview' clip based on the clip used as additive animation. Any frame lookup will be done relative to this preview clip. Unfortunately, these additive reference pose clips cannot be set in the animation clips of an asset. The only way to work around this bug is to duplicate these clips to stand-alone assets, and then set the reference pose clip to an idle animation (or whatever animation is to serve as a basis). The downside here is that updating the original asset will not update these duplicate clips.
     
  8. 5argon

    5argon

    Joined:
    Jun 10, 2013
    Posts:
    1,184
    lol lose 2 hours before finding this thread. Additional clarification since this came up the top from Google, important rule :

    https://docs.unity3d.com/ScriptReference/AnimationUtility.SetAdditiveReferencePose.html

    Without entering Debug mode, if we have an additive layer with full weight, both base layer and additive layer playing single state

    Screenshot 2019-05-19 15.38.07.png

    Situation 1

    Base layer : single keyframe, looping, position x = 5
    Additive layer : single keyframe, looping, position x = 1

    Expected : constant position x = 6
    Result : constant position x = 5, because the additive layer reference the first frame of itself, which has position x = 1. When it is playing, it is always 1 - 1 = 0 so nothing got added.

    Situation 2

    Base layer : single keyframe, looping, position x = 5
    Additive layer : 2 keyframes, looping, position linearly ramp up from x = 0 to x = 1

    Result : position ramp up from x = 5 to x = 6. Additive layer use the first frame of itself as a reference like before but this time it's x = 0. Overtime we get +0 ~ +1 to the base layer correctly. You can also adjust the total addition with Additive layer's weight.

    Situation 3

    I want to upgrade the ramp, so I made the 2 keyframes that was ramping up from x = 0 to x = 1 to become x = 3 to x = 4 instead.

    Expected : position ramp up from x = 8 to x = 9
    Result : position still ramp up from x = 5 to x = 6. Again, since the additive clip use the first frame of itself as a reference, we get 3 - 3 = 0 ~ 4 -3 = 1 -> still ramping up from +0 ~ +1

    How to make the first situation producing constant x = 6, and the 3rd situation producing ramping up x = 8 to x = 9?

    Make a custom reference clip. It doesn't have to be in the graph, but you should copy from your previous clip so it has a Position keyframe. (If it is not in a graph, you cannot key a new kind of keyframe to it from "nothing", but you could delete keyframes) Make it a single keyframe with 0 0 0 position.

    Screenshot 2019-05-19 15.46.45.png

    Enter debug mode of the additive clip with a single keyframe position x = 1. Connect the zero reference clip and check has additive reference pose check box. Now x = 1 will be 1 - 0 = 1 correctly and not 1 - 1 = 0, and produce a constant x = 5 + 1 = 6 when playing additively.

    Screenshot 2019-05-19 15.47.31.png

    (imo this box should be exposed, especially that I am doing UI animation where there is a lot of single frame animation that I want them added it is not obvious that I have to enter Debug mode.)
     
    Last edited: May 19, 2019
    teutonicus likes this.
  9. alanmthomas

    alanmthomas

    Joined:
    Sep 7, 2015
    Posts:
    112
    I agree that this should be exposed. And thank you so much for this post! I've been trying to get additive blending to work properly and couldn't until I got here. I found a lot of "use override" posts, which really don't do the trick.

    Thanks again!