Search Unity

Mecanim Additive Look Animation

Discussion in 'Animation' started by PhobicGunner, Sep 15, 2014.

  1. PhobicGunner

    PhobicGunner

    Joined:
    Jun 28, 2011
    Posts:
    1,813
    So, working on a shooter, and I need a character to be able to aim around. So assuming I have:
    -Look Up
    -Look Down
    -Look Left
    -Look Right

    I would put these in a 2D blend tree which blends with LookX/LookY. However, the problem is getting these to play nicely with the rest of the animation tree.

    Ideally, the animations would just be additive, so they'd be added on top of everything (I do not want the animation to override the upper body, I only want it to add on top). However, the problem is that in Mecanim additive animations are relative to the first frame of the animation. Meaning, for say a Look Up animation where the character is just aiming up for the animation, there would be no delta between first and subsequent frames, therefore the animation would add nothing.

    But surely, there must be a way to accomplish this in Mecanim? Am I missing something?
     
  2. thleonar

    thleonar

    Joined:
    Dec 7, 2013
    Posts:
    6
    Did you find a way to resolve your problem? I'm having this exact same issue.

    Thank you!
     
  3. PhobicGunner

    PhobicGunner

    Joined:
    Jun 28, 2011
    Posts:
    1,813
    Yes. It turns out, this is what you do:

    You need one animation for each look direction:
    - Look Up
    - Look Down
    - Look Left
    - Look Right

    For each of these animations, it needs to be a sweep - that is, the animation starts on the first frame pointing straight forward, and over the duration of the animation it "sweeps" to looking in the appropriate direction (up, down, left, or right). This sweep should be fairly quick. The sweep is very important, as it's how they will work properly when additively blended.

    When you import these animations, you set them to not loop. That way, it clamps at the end pose.
    Then you can just stick them in a blend tree on an additive layer and you're all set.
     
  4. Mecanim-Dev

    Mecanim-Dev

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

    Like you said additive layer is somehow broken right now because the delta to add is the difference between first frame and current frame. This workflow doesn't work in most case like for aiming.

    Your workaround will work but you may notice it sometime if the frame rate drop.

    We are working on an improvement that we would like to release as soon as possible because it a shame right now how additive layer work. We would like to add a motion field on Animator State when they are in a additive layer, this motion field will be used to define the reference pose. So for your example you would set the reference pose on the state containing your 2d blend tree and all the leaf node would use this reference pose to compute the delta animation rather than using the first frame of the animation.
     
  5. PhobicGunner

    PhobicGunner

    Joined:
    Jun 28, 2011
    Posts:
    1,813
    Good to hear. That's how it works in Source engine as well, IIRC
     
  6. thleonar

    thleonar

    Joined:
    Dec 7, 2013
    Posts:
    6
    It seems to kinda work.

    However, as I trigger any animations from the base layer (Run, Reload, Fire, Aim, etc.), I'm seeing a weird behavior for each animations. The bones doesn't seem to react properly to the additive layer. It starts without any effect at 0 Degree and it get distorted as I go to 90 or -90 degrees. See the hand in the attached image.

    Reload.jpg

    Anyone has an idea?

    Thank you!
     
  7. PhobicGunner

    PhobicGunner

    Joined:
    Jun 28, 2011
    Posts:
    1,813
    How does your aim animation look? Ideally the animation doesn't affect the arms at all, just the spine.
     
  8. thleonar

    thleonar

    Joined:
    Dec 7, 2013
    Posts:
    6
    I tried masking the spine only to the additive layer. It works great, but I would love to have a motion in the arms as I look up or down. Otherwise, it seems to work as it should be.

    Big Thanks!