Search Unity

Help Wanted Blend Shape copied to new mesh missing in animation clip

Discussion in 'Animation' started by syobe0808, Nov 24, 2021.

  1. syobe0808

    syobe0808

    Joined:
    May 17, 2017
    Posts:
    4
    I copied blend shape origin mesh to new mesh.
    It seems to copy completely as you can see below screenshot. But It's not working in animation.

    Mesh sourceMesh = _smRenderers[i].sharedMesh;
    Mesh targetMesh = smr.sharedMesh;
    Vector3[] deltaVertices = new Vector3[sourceMesh.vertexCount];
    Vector3[] deltaNormals = new Vector3[sourceMesh.vertexCount];
    Vector3[] deltaTangents = new Vector3[sourceMesh.vertexCount];
    for(int shapeIndex = 0; shapeIndex<sourceMesh.blendShapeCount; ++shapeIndex)
    {
    string shapeName = sourceMesh.GetBlendShapeName(shapeIndex);
    if(targetMesh.GetBlendShapeIndex(shapeName) < 0)
    {
    int frameCount = sourceMesh.GetBlendShapeFrameCount(shapeIndex);
    for(int frameIndex = 0; frameIndex<frameCount; frameIndex++)
    {
    float frameWeight = sourceMesh.GetBlendShapeFrameWeight(shapeIndex, frameIndex);
    sourceMesh.GetBlendShapeFrameVertices(shapeIndex, frameIndex, deltaVertices, deltaNormals, deltaTangents);
    targetMesh.AddBlendShapeFrame(shapeName, frameWeight, deltaVertices, deltaNormals, deltaTangents);
    }
    }
    }

    this is my copy code.
    (it refered https://extra-ordinary.tv/2020/09/07/copying-blendshapes-in-unity-with-a-script)
    So I check animation clip in animation window. Blend shape in animation clip is missing.
    I think link is broken during copy mesh to mesh.
    upload_2021-11-24_10-13-4.png

    can you guys help me ?
     
  2. syobe0808

    syobe0808

    Joined:
    May 17, 2017
    Posts:
    4
    any one any idea???
     
  3. 00christian00

    00christian00

    Joined:
    Jul 22, 2012
    Posts:
    978
    Blendshape retargeting can be a mess, it needs to have the exact name to work. I see the animation windows says "Basic_Face", try renaming your face gameobject like that instead of the current "FACE_O".
    Also check the blendshape name is all the same, from blendshape name to each blendshape target.
    I don't see the blendshape name in your skinnedmesh renderer, in my case it is named like this "blendshapename.blendshapetarget".
     
  4. syobe0808

    syobe0808

    Joined:
    May 17, 2017
    Posts:
    4
    Thank you very much~!!
     
unityunity