Search Unity

There are some bug with unity 2019 about boneindex.

Discussion in 'Animation' started by chuyuwei, Oct 12, 2019.

  1. chuyuwei

    chuyuwei

    Joined:
    May 29, 2019
    Posts:
    19
    I want to access the boneindex and boneweight from SkinnedMeshRenderer.But I find some bug. In 2000+ vertices, about three vertices' index is error,others is true. The true index is 19 18 and the true weight is 0.48 and 0.56.
    But, it show 18,19 index and 0.48,0.56weights. It change the indexes and i try it in unity 2018 and unity 5, it is absolute true. It is strange.
    Only when I access the boneindex by code ,it is false. The unity animation is true. It is in the copying or accessing from mesh.bone
    The code is:

    SkinnedMeshRenderer smrt = oriPrefab.transform.Find("hnpc040").GetComponent<SkinnedMeshRenderer>(); //oriPrefab.GetComponentsInChildren<SkinnedMeshRenderer>(true);
    using (StreamWriter outputFile = new StreamWriter(@"C:\Users\chuyuwei\Desktop\daiding.txt"))
    {
    for(int i=0;i< smrt.sharedMesh.vertices.Length;i++)
    {
    Vector4 pos = smrt.sharedMesh.vertices;
    BoneWeight bw = smrt.sharedMesh.boneWeights;

    outputFile.WriteLine(pos.x + " " + pos.y + " " + pos.z);
    outputFile.WriteLine(bw.boneIndex0 + " " + bw.boneIndex1 + " " + bw.weight0 + " " + bw.weight1);
    outputFile.WriteLine(smrt.bones[bw.boneIndex0] + " " + smrt.bones[bw.boneIndex1]);
    }

    }