Moving Bones without moving Mesh

I posted this on the unity answers site a while ago but no one responded, so I’m giving it a shot here:

I have a rig imported from Maya which has a few Meshes in it which are driven by bones.

During game play I want to be able to modify the mesh, and then move the bones so they align with the new mesh. For example, if I have a bone which is positioned flush with the mesh, and then the mesh becomes wider, I want to move the bone so it is still flush with the mesh.

I have tried to move all the bones, and then apply the mesh vertex positions, but this doesn’t seem to be working. When we try this, we still see the bones having an effect on the vertices.

Is there any way to move the bones in script without moving the mesh with it? This way I can assign the mesh to be whatever values I want, and then just move the bones to match my new mesh and then hook up the bones so they drive the mesh again.

From what I can tell, I’m going to need to programmatically re-rig the mesh and the bones, which I assume isn’t going to be trivial. (Something like: destroy all bone/mesh connections, move the bones and the meshes to their new positions, and then reconnect the bones to their respective vertices with the appropriate weighting.)

Thanks in advance,
Liron

You can rebuild the mesh.bindposes array.

Check out this example: Unity - Scripting API: Mesh.bindposes

1 Like

@IGY-United could you elaborate a little more? that example is not really clear what’s going on