Search Unity

Ik on scaled bones get an offset

Discussion in 'Animation' started by gluckez, Dec 15, 2019.

  1. gluckez

    gluckez

    Joined:
    Oct 13, 2015
    Posts:
    1
    I am working on a character of which the bones can be scaled.
    For the feet i am using the built in IK System, where i get the targets by a raycast.
    (this all works fine, the ik targets are being set, and the capsule colliders position
    is offset, based on the size of the legs).
    The problem i am facing now, is because the legs have been scaled,
    the IK position is offset. That means, when i scale the legs to about 80 %,
    the Ik target is still put in the right position, but it's bending his legs, as if
    the target was higher.
    Same happens when i scale them to 120%, only now it's stretching it's legs to below
    the ground.
    I believe this is a bug, just posting here to see if anyone has come across this before.
    code is fairly simple, it has nothing to do with that:

    Code (CSharp):
    1. if (Physics.Raycast(_currentIkPosition + Vector3.up, Vector3.down, out RaycastHit hit, 10.0f, GeometryDetector.LayerMask))
    2.             {
    3.                 Debug.DrawLine(hit.point, hit.point + hit.normal, Color.yellow);
    4.  
    5.                 _Animator.SetIKPosition(avatarIkGoal, hit.point + OffSet);
    6.  
    7.                 _Animator.SetIKRotation(avatarIkGoal, Quaternion.LookRotation(Vector3.ProjectOnPlane(RootObject.transform.forward, hit.normal), hit.normal));
    8.                
    9.  
    10.             }
     
    unity_p6iBAqjTDMjf9g likes this.