Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

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