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

Stuck with IK -- any good step by step Inverse Kinematics tutorials?

Discussion in 'Animation' started by guru20, Jul 13, 2016.

  1. guru20

    guru20

    Joined:
    Jul 30, 2013
    Posts:
    239
    I've looked through Unity documentation/manual, a few YouTube videos, and a Lynda.com tutorial, and yet can't seem to get IK to work. Anybody know of a really good basic tutorial that walks through every step, step by step?

    A few questions, before I describe my situation:
    1) Does the animator HAVE to have a default (idle) animation assigned? Or can it just have an avatar and an animator controller with no clips?
    2) Is an avatar mask necessary? I saw one youtube video using a mask, but the documentation and Lynda tutorial make no mention of that...

    So, my situation is this:
    I made a model and set it up in 3DSMax.
    I rigged it using Mixamo.
    I imported the rigged (skeleton/skin) FBX into Unity, but with no animation.
    I created an Animator Controller and assigned it, turning IK pass on the base layer.
    I created and attached a C# script to set a hand's IK Weight and Position to an assigned object's transform (during OnAnimatorIK)

    Nothing happens.

    So I went back to Mixamo, assigned an idle animation to test with, imported that FBX and set that idle animation as the default/entry one in the controller...
    Still nothing happens (well, the idle animation happens -- but no IK stuff occurs)

    Anybody know what I might be doing wrong??
     
  2. TrickyHandz

    TrickyHandz

    Joined:
    Jul 23, 2010
    Posts:
    196
    What type of rig is Unity set to use when importing your character? I'm not sure if anything other than Humanoid is supported for IK. That may be the problem. I don't have a test project available right now, but I may be able to set one up later if need be.
     
    theANMATOR2b likes this.
  3. guru20

    guru20

    Joined:
    Jul 30, 2013
    Posts:
    239
    Helpful, thanks!
    I was placing asset directly into folder without importing it and without checking those rig settings, so it was set on generic instead of forcing to Humanoid...

    (going to Humanoid rig worked for IK, even without animation -- although the Mixamo animations no longer work on the rig. Go figure. I think I have to blame this one on Mixamo... annoying, because they make some super time-saving tools and really speed up the workflow, but ever since getting bought by Adobe, the site/services have become crippled/user-unfriendly, and their own instructions/tutorials no longer apply to their new UI)
     
  4. TrickyHandz

    TrickyHandz

    Joined:
    Jul 23, 2010
    Posts:
    196
    Just make sure that your animations are also set to use a Humanoid Rig and you should be okay for using them.
     
    theANMATOR2b likes this.
  5. ZJP

    ZJP

    Joined:
    Jan 22, 2010
    Posts:
    2,649
  6. landon912

    landon912

    Joined:
    Nov 8, 2011
    Posts:
    1,579
    ZJP likes this.
  7. guru20

    guru20

    Joined:
    Jul 30, 2013
    Posts:
    239
  8. theANMATOR2b

    theANMATOR2b

    Joined:
    Jul 12, 2014
    Posts:
    7,790
    Correct me if Im wrong - without checking any resources - isnt IK supposed to be applied to the top most layer, so it overrides the animation layers below it.

    This might be where the avatar or layer mask comes into effect - and will allow animations to be played with the IK overriding the animation.
     
  9. LaneFox

    LaneFox

    Joined:
    Jun 29, 2011
    Posts:
    7,462
    Have you checked this page out? Might help do some comparisons.

    There is a pass for each layer, the IK will override the layer it is on. Layer override sequence is top to bottom with bottom being the last to be processed. So if you have an upper body layer at the top with IK on it (Layer 1) then it will override the animation on that layer to do the IK, next you can have a reload layer below it (Layer 2) and just adjust the weight of it when you want the animation to take precedence over IK. Zero weight means it does not show up, 1 weight means it completely overrides.

    Kind of rusty, but I'm fairly certain that is accurate.
     
    theANMATOR2b and eses like this.
  10. theANMATOR2b

    theANMATOR2b

    Joined:
    Jul 12, 2014
    Posts:
    7,790
    Me too. Thanks for the clarification Lane - I knew layers were important when I dealt with it last, I just couldn't remember, and didn't have enough motivation to check my resources.
     
    LaneFox likes this.