Search Unity

IK and Animation Layers

Discussion in 'Animation' started by tborden, Oct 28, 2019.

  1. tborden

    tborden

    Joined:
    Sep 5, 2017
    Posts:
    3
    I have a first person shooter setup, where I'm positioning the gun, and then using IK to position both hands correctly on the gun. I have an additive layer above (further down the layer list) the one doing the IK with a fire animation, in which the hands quickly recoil backwards and then move back to their original location. Since the hand IK layer is beneath the additive layer, I had thought that the additive fire animation would displace the hands relative to their IK-driven position from the layer beneath it, but it seems as though the IK is applied after *all* the layers, because offset from the additive fire animation apparently gets overwritten by the IK pinning the gun and hands in place.

    Is this not how IK and animation layers interact? And if IK evaluation cannot be interleaved with anim layer pose evaluation, what is the typical approach to creating the type of behavior I'm looking for? In other words, how do I layer displacement on top of my IK target positions, so that joints being positioned by IK aren't always frozen in place? I'd like to be able to use IK to "correct" weapon positioning and hand placement without overwriting the drifting motion coming from my idle animation or the kick from my fire animation.
     
  2. launzone

    launzone

    Joined:
    Dec 2, 2015
    Posts:
    57
    how about animating the object that the IK targets are parented to? (in this case the gun)
     
  3. Somnesis

    Somnesis

    Joined:
    Feb 27, 2020
    Posts:
    32
  4. halley

    halley

    Joined:
    Aug 26, 2013
    Posts:
    2,439
    Don't dredge up ancient threads, man.

    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 here: 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.