Search Unity

Rebinding SkinnedMeshRenderer to new bones.

Discussion in 'Animation' started by adehm, Jul 15, 2021.

  1. adehm

    adehm

    Joined:
    May 3, 2017
    Posts:
    369
    I would like to know how to write in bone weights so that I can link clothing to new bones.

    For instance I use a clothing item meant for a particular skeleton, in which I had rewritten bone names to unify all of these identical skeletons; identical except naming prior to rewrite. I can rewrite the bones for the SkinnedMeshRenderer to match the skeleton I intend it to use and it fixes it to the correct position.
    Code (CSharp):
    1. Transform[] bones = new Transform[3];
    2. bones[0] = root;
    3. bones[1] = root.GetChild(0);
    4. bones[2] = bones[1].GetChild(0);
    5. skinnedMeshRenderer.rootBone = root;
    6. skinnedMeshRenderer.bones = bones;
    I did not have to rewrite these bone weights due to them being meant for this skeleton. Upon debugging there is 613 of these indexes*4/weights*4; however I cannot understand why so many for three bones or what their values represent nor how I would translate them for my needs.


    So when trying to translate a mesh bound to a different skeleton it will not work and I have no idea how I would write these weights to fit my skeleton. What I am trying to achieve is to write classes for each clothing position that will set new bones and weights for the mesh in order for them to work for my skeletons.