- Home /
Skinning a mesh by Code...
Hello everyone!
Ok, I've search on the web and can't find anything about this. I would like to re-use several animations on a custom mesh that will share the same bone structure.
If you import an animated mesh in Unity, it has:
-The bones structure has child object
-A SkinnedMeshRanderer component
-An Animation component.
In my case, the mesh will be created by the player, and therefore, can't be animated beforehand.
I know that my bones structure will always be the same, because it's a gameplay restriction. The problem is that if I apply a SkinnedMeshRenderer component by code and fill it properly, Unity throw me: "SkinnedMeshRenderer requires a mesh with skinning information."
Any idea how I can provide those skinning information?
Answer by Loius · Nov 01, 2013 at 11:41 PM
(for reference: http://docs.unity3d.com/Documentation/ScriptReference/Mesh.html)
You'll need to fill in the bindPoses and boneWeights arrays yourself. BoneWeights is pretty simple, but bindPoses involves matrices. I believe they're the rest positions of the bones? If your two renderers are similar enough it should be okay to copy the bindPoses and boneWeights from the working mesh to the one that isn't bound.
You may also need to arrange the bones in the SkinnedMeshRenderer.bones array yourself in the new mesh.
Your answer
![](https://koobas.hobune.stream/wayback/20220613092926im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Distribute terrain in zones 3 Answers
How to control bones with code? 0 Answers
Attaching an object to an ongoing animation 1 Answer
Bones move mesh in editor but not in run?? 1 Answer
Multiple Cars not working 1 Answer