expected Joint Positions are offset from IK position with custom avatar
On my current project I have created a character customization script that squashes and stretches our default character by manipulating joint positions. When the user is done manipulating the character, I write out a new avatar definition with all the updated bone positions. Everything has been working fairly well until I started working with the IK for the arms.
I'm using animator.SetIKPosition() , and the arm joints are offset very far from the actual IK location. I'm displaying the location of the IK and joints and can see everything moving in real-time, but its all offset (roughly by the amount that I stretched the character). While the game is running, if I drop the original avatar back onto the animator, then all the arm-joints seem to line up with the IK.
Am I possibly missing a step when creating the avatar? I'm taking the original human description, making a copy of it, modifying all the joint positions as necessary, and then using that human description when I make a new avatar. It seems like the IK is using the original avatar skeleton positions, but visually I'm seeing the new avatar? I'm pretty stumped at this point. Tried debugging everything under the sun. Any clues or suggestions would be really helpful at this point.
I've tried offsetting the IK by the amount that I stretched out the character, but it still seems to be pretty off no matter what I do. The image below has the Ik handle in red on the gun and the arm joints are in green.
UPDATE: When I use Animator.SetIKPosition() is it getting the joints from the avatar directly or is there some other cached data somewhere? I tried saving out my modified avatar definitions to disk first and then dropping one of the files on a character's animator component directly vs doing everything on start, Same results, Bones are always offset from where the IK is. Maybe something to do with the muscle definition?
UPDATE: I've narrowed it down to the Arm Stretch feature under the Muscle settings. When I set the arm-stretch to 0, then the hands line up with the expected IK position. This makes me think that I'm not doing something right with the muscles when I create the custom Avatars in my script. The arm-stretch works with my default avatar but the joint positions are really far off when I use the custom avatar. Anyone know what to look for with the muscles? This make sense to anyone else that has experience with mecanim and the muscle settings?