- Home /
Make one skinned mesh with weighted bone values take on the bone movement of a main skeleton?
My problem is i am getting a model that has been bone weighted in, this is a piece of armor. When i step through the piece of armour it has only 23 binding poses while the main body i am attaching it to has 29 .. this seems to pinch a bunch of the verticies into a center after i assign the 29 bones from the body mesh to it . 80% of the armour looks fine but the chunks that are moving with the body are all pinched into the center.
Any Ideas?
public void SetMaterialForSkinnedMesh(SkinnedMeshRenderer renderer, MeshFilter filter, k.RarityType rarity)
{
// renderer.rootBone = body.rootBone;
renderer.sharedMesh = filter.sharedMesh;
Transform[] bones = new Transform[renderer.sharedMesh.bindposes.Length];
for (int i = 0; i < renderer.sharedMesh.bindposes.Length; i++)
bones[i] = boneMap[i];
renderer.bones = bones;
// for (int i = 0; i < renderer.sharedMesh.bindposes.Length; i++)
// {
// renderer.sharedMesh.bindposes[i] = renderer.bones[i].worldToLocalMatrix * transform.localToWorldMatrix;
// }
renderer.sharedMaterial = Game.Instance.Materials[rarity.ToString()];
}
$$anonymous$$ight be because of weightless bones don't get added to Skinned$$anonymous$$eshRenderer bone array.
This could also be an issue when generating or exporting the models from your program. For example, when skinning in $$anonymous$$aya, there's an option to 'remove unused influences' that causes a problem like this in Unity. Check your source assets.
Answer by JayemJigga · Feb 19, 2016 at 12:41 AM
Solved My Issue, This was due to the model coming in with 23 bones .. through code i was assigning it 29 of the bones from my main body. After Making a dictionary of the main bones from the body i was applying the mesh to, i then only applied the bones that mattered for this specific skinned mesh. After doing that it moved perfectly fine with the model.
Your answer
![](https://koobas.hobune.stream/wayback/20220612064739im_/https://answers.unity.com/themes/thub/images/avi.jpg)