Search Unity

Question Additive animations on top of IK

Discussion in 'Animation' started by Somnesis, Aug 2, 2022.

  1. Somnesis

    Somnesis

    Joined:
    Feb 27, 2020
    Posts:
    32
    Technically this should work but it doesn't seem to.

    My setup:
    1. Base layer 0 (with IK)
    2. Gestures layer 1 (additive)
    3. OnAnimatorIK() on layer 0, I tell it to do a look at using SetLookAtPosition and SetLookAtWeight
    4. On the gesture layer I play a gesture

    My expectation is that since the gesture layer exists *above* the base layer and is *additive*, playing an animation there (eg. a nod) should add that animation to the look at that's going on in layer 0. However, it seems like if I have the IK lookat going on in layer 0, it nullifies the additive nod that I play on layer 1 (at lease the effect of that nod on the bones that the look at is using).

    Is this a bug in Mecanim? Or am I doing something wrong? Any way to work around this or do what I'm after in a different way?

    Using Unity 2022.1.

    Thanks!
     
    MrEloda likes this.
  2. Somnesis

    Somnesis

    Joined:
    Feb 27, 2020
    Posts:
    32
    Hey just giving this a bump. Still struggling with the same issue in Unity 2023.2.

    Anyone tried to do the same thing and worked around it?

    Specifically I'm using the OnAnimatorIK to set the look ats for a character using SetLookAtPosition and SetLookAtWeight.
     
    Last edited: Apr 10, 2024
  3. halley

    halley

    Joined:
    Aug 26, 2013
    Posts:
    2,445
    In almost any animation setup, IK is done after animations. Usually it's in LateUpdate after all of the animation stuff is done during Update, but the Unity-built-in IK is interleaved between Update and LateUpdate. Layers have nothing to do with it. @launzone has a good idea from your other thread: if you want to adjust what IK did procedurally, you will need to do it in an even later-than-IK phase, potentially with a high Script Execution Order / DefaultExecutionOrder specified on your scripts.

    https://docs.unity3d.com/Manual/ExecutionOrder.html
     
    Somnesis likes this.
  4. Somnesis

    Somnesis

    Joined:
    Feb 27, 2020
    Posts:
    32
    Problem is that what I need is to be able to play *any* animation additively *after* the IK happens, not just futz around procedurally with what the IK is doing. In my example above the animation is a nod, but there will be a whole library of animations that will play in this way. It's not feasible to procedurally re-implement each of those in code. So @launzone's solution doesn't make sense here.

    Seems to be an entirely reasonable thing to want a character to be able to look at something, and also do a nod on top of that. If there isn't a way to do that with IK look ats, then we'll need to need to find a different solution to do look ats (or anything else we're doing with IK) to not be using IK.