Search Unity

Bug Scaling bone(s) breaks Two Bone IK Constraint

Discussion in 'Animation' started by Geist2501, May 24, 2021.

  1. Geist2501

    Geist2501

    Joined:
    Jun 29, 2019
    Posts:
    25
    TLDR: I built a body ik rig for VR, then added a calibration system for biometrics. After scaling bones to match my body's the IK Constraints seem to ignore the new values and projections are offset/ wrong.

    If I scale any of the bones making up my players body(to match his/ her irl body), the ik-chain seems to not update these values and the result is offset (hand or feet are not projected to the right position, but to where they would have been if no bones had been scaled, at lest that is how it looks like). Obviously I need to scale the player's skeleton at runtime for in-game calibration.

    I guess that the bone length is cached to speed up real-time calculations and such, but there seems to be no way to force a "re-calculation and re-caching". Is that right? In that case i would have to fall back to other IK solutions... I'm not sure that is intended behavior... so i just let y'all know.

    Reproduction is easy: Build any IK rig and afterwards scale the involved bones to 1.1 and observe the offset projection. I'm using version 0.2.7 and Unity2019 LTS
     
  2. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Unity doesn't have guaranteed behaviour for nonuniform scaled bones. This should work fine what you're doing but you can't scale one axis more than another without rotations breaking.

    It's a limitation of the transform hierarchy not IK in general. To get around this you could have dummies or a proxy.

    You can try it by making a rig of boxes, some children and experiment with nonuniform scaling, then rotate some and you'll see it all break down with or without IK.

    If your use case allows uniform scaling (each axis has the same value for scale) and it still breaks, then it's probably an oversight or bug.
     
  3. Geist2501

    Geist2501

    Joined:
    Jun 29, 2019
    Posts:
    25
    Thanks for the fast reply! Sadly, whether the bones are scaled uniformly or only on one axis makes no difference.

    I tried whether uniform scaling would make any difference first thing after encountering the problem. There is also no distortion in the geometry like usually when you got these problems you talk of. It just seems to do the calculations on the unscaled bones (or as if they where not scaled) and then apply these angles to the scaled bones. Like you are in a mech suit or something. Also regardless of whether scaled in editor or at runtime.

    I "quickly" checked to be sure.
    It does work fine with Final IK and other solutions, one that i wrote and one found open source.
    So, while i might be mistaking of course, i think it is a problem with the specific IK solution, the Two Bone IK Constraint.

    Thanks for taking the time though! I can for now mix and match other working solutions, It would just have been more comfortable to do everything with one.

    I am not sure i should have mentioned, but i work with Unity since 2006 and i'm aware of these limitations. I just am not a big forums guy and I tend to forget my logins about once a year - so i look like a noob :D
     
  4. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Yeah I don't judge how long people have used unity, only make posts that will benefit future as well as present readers. So not a personal observation :)

    In any case it's bugged then.
     
    Geist2501 likes this.
  5. humanMusic

    humanMusic

    Joined:
    May 16, 2017
    Posts:
    16
    I'm still trying to figure this out too, like geist said the bone scales but the ik is still using the old dimensions. Might go with final ik but I feel like something can make it work with the unity system.