Search Unity

Question Two Bone IK with Stretch Bones

Discussion in 'Animation Rigging' started by bart_artanim, Aug 25, 2022.

  1. bart_artanim

    bart_artanim

    Joined:
    Jul 18, 2018
    Posts:
    19
    I'm trying to convert a simple arm IK setup in our VR project to something based on the Animation Rigging package. Our current setup evaluates if the arms of the model are long enough to reach the target (driven by hand tracking of the user), and if not, it allows for a bit of bone stretch by modifying the local positions of the relevant joints in the hierarchy.

    I've tried to integrate that principle in what is basically a modification of the standard Two Bone IK script. I find that while all the updates do seem to happen correctly (from debugging the calculated values), the updated local positions applied to the ReadWriteTransformHandle do not persist. It seems something somewhere resets the Humanoid avatar's hierarchy to its original definition.

    Functionally the same code works fine with making it a non-job, not animation rigging, bog standard bit of Transform manipulation in a MonoBehaviour.

    The avatar has an Animator, with a valid avatar, but no active animation. Is the behaviour described above expected? Is there a way to work around this?
     
  2. simonbz

    simonbz

    Unity Technologies

    Joined:
    Sep 28, 2015
    Posts:
    295
    Hi,

    When using constraints on a humanoid character, you have to be careful that the changes you make are compatible with humanoid. I'm guessing the local position offset you've added in the two bone IK does not convert back to human curves like you would expect, and thus is lost in the final pose. You can refer to my post on the subject that explains it a bit more:

    https://forum.unity.com/threads/ongoing-humanoid-issues-in-animation-rigging.1080695/#post-7141781

    You could try the exact same setup with a generic character instead to see if this would work.

    Otherwise, this is a limitation of the humanoid system I'm afraid.
     
  3. bart_artanim

    bart_artanim

    Joined:
    Jul 18, 2018
    Posts:
    19
    Unfortunately a humanoid character is a requirement for what we do, so that's unfortunately the end I guess. We can go the route of creating a new Avatar at runtime, but that comes with its own heap of issues and won't perform well.
     
  4. Hauchris

    Hauchris

    Joined:
    Jul 20, 2017
    Posts:
    1
    I'm working on a similair problem. Also VR also humanoid avatar. While changing the hand position of the avatar is not working, changing the scale of previous components of an Avatar works with Bone IK Constraints. For example it is possible, dependent on the model, to change the local scale of the arm and forearm of a humanoid model, which in turn will stretch the hand position further out. It is not a perfect solution, but it does help in our case.
     
    Promokot likes this.
  5. fashVR

    fashVR

    Joined:
    Aug 31, 2020
    Posts:
    3
    Hey , I hope you will see this. can you please tell me how did you stretch the arm and forearm? when I try to do that nothing happens, it seems like the two-bone IK constraint just locks the bones attributes to their original setting. I've been trying to figure that out for three days now...
     
  6. humanMusic

    humanMusic

    Joined:
    May 16, 2017
    Posts:
    16
    I'm able to scale the bones but then the IK doesn't work very well. Seems like it still has some original settings like fashVR mentioned. Any way to access those settings?
     
  7. fleity

    fleity

    Joined:
    Oct 13, 2015
    Posts:
    345
    I am trying to do this with a generic rig character.
    The animations simply played through an animator controller are able to stretch the limbs using transform position, scaling is at 1, 1, 1 all the time, all fine. But with the animation rigging package I can't stretch the limbs. I guess because the Two Bone Ik constraint only writes rotation for assigned bones?
     
  8. King_of_L1mbs

    King_of_L1mbs

    Joined:
    Jun 15, 2019
    Posts:
    22
    Well since I just found a solution for a humanoid avatar: For one of course the Code of the Two Bone IK Constraint Job needs to be modified, but what took me long hours to realize was that to not only control rotation but position too was to Enable the Translate DoF option in the Additional Settings of the Avatar.
     
    fleity likes this.
  9. fleity

    fleity

    Joined:
    Oct 13, 2015
    Posts:
    345
    This is literally on my to do list (for generic) right now. Any other pitfalls one should know about?