C# 统一:骨骼变换位置不一致

C# 统一:骨骼变换位置不一致,c#,unity3d,C#,Unity3d,我想做的是通过设置衣服中每个骨骼的变换与人体模型中相应的骨骼相同,将衣服附加到化身上。 然而在实验中,我注意到骨骼的位置由 bone.transform.position; 与场景中的实际位置不同 例如,在“头部”骨骼上运行代码时,上述代码会产生位置(1.6,18,-.04),但当我进入场景并检查骨骼时,其位置为(-0.7700785,1.117587e-07,-2.235174e-08)。正如你可能想象的那样,这严重扰乱了整个过程 以下是相关方法: //copies the bone tra

我想做的是通过设置衣服中每个骨骼的变换与人体模型中相应的骨骼相同,将衣服附加到化身上。 然而在实验中,我注意到骨骼的位置由

bone.transform.position;
与场景中的实际位置不同

例如,在“头部”骨骼上运行代码时,上述代码会产生位置(1.6,18,-.04),但当我进入场景并检查骨骼时,其位置为(-0.7700785,1.117587e-07,-2.235174e-08)。正如你可能想象的那样,这严重扰乱了整个过程

以下是相关方法:

//copies the bone transforms from the model to the desired article of clothing
private void CopyBones (GameObject art)
{

    //for each bone in the model, modify the corresponding bone in the article
    foreach (string path in bonePaths)
    {

        Transform fromBone = art.transform.Find("Armature/" + path);
        Transform toBone = model.transform.Find("Armature/" + path);

        if (fromBone == null || toBone == null)
            Debug.Log("Could not locate: " + path);

        else
        {

            //doing this doesn't work for some reason
            //fromBone.SetPositionAndRotation(toBone.transform.position, toBone.transform.rotation);

            fromBone.transform.position = toBone.transform.position;
            fromBone.transform.rotation = toBone.transform.rotation;

            //doing this doesn't work either
            //fromBone.SetParent(toBone);
            //fromBone.localPosition = new Vector3(0, 0, 0);
            //fromBone.localRotation = Quaternion.Euler(0, 0, 0);

        }
    }

}

这个问题可能已经过时了,但这是我发现的唯一一个与我自己的问题有关的问题。也在寻找关于这个的解释。。。