- Home /
Weightless bones don't get added to SkinnedMeshRenderer bone array?!?
Kinda obscure question I guess :)
I think I have found out that Unity3D doesn't add weightless bones to the bones array that is part of the object's SkinnedMeshRenderer component. The complete skeletal structure appears perfectly fine as part of the hierarchy, but it's not part of the bones array.
By weightless bone I mean a bone that does not affect any vertices.
This gets important when using shared meshes, like a piece of clothing that is rigged with the same bones inside the 3D modeling application and then cycles through all the wearer's bones to assign it's own ones to it... As in this method:
http://answers.unity3d.com/questions/44355/shared-skeleton-and-animation-state.html
Any ideas how to deal with that issue (if it actually is one)?
Answer by Cherno · Mar 20, 2014 at 03:18 AM
Got the solution with a lot of web research:
The FBX exporter ignores unused bones when it comes to exporting teh vertex weights, so they show up as the hierarchy in Unity but are not added to the bones array of the SkinnedMeshRenderer component.
The solution:
Give the missing bones a keyframe and/or a weight (it's enough if it's just 0.01 for the single closest vertex).
Original thread here:
http://answers.unity3d.com/questions/166568/skinnedmeshrenderer-missing-bone.html
I found a method that doesn't add "real" weight:
It is true that the FBX exporter doesn't add weightless bones to the skinned mesh (they export as objects normally). Thus, the bones array of the Skinned$$anonymous$$eshRenderer in Unity has only those bones which have a weight to them. The trick is to give each bone a weight in $$anonymous$$ax... But this weight can be 0! As long as the weight table doesn't read "-", the bone counts are being weighed and will be fine. I just marked all vertices inside the weight table and typed in a value 0f 0.01 for all bones, then typed in 1.0 for the one bone that actually needed to influence vertices (a weapon, in this case). The other weighs will then be set to 0 (but not "-"). For complex rigs, it might be neccessary to set the Bone Affect Limit higher (in the Skin $$anonymous$$odifier's Advanced Parameters Rollout).
Similar question by etreworgy:
Thanks, Cherno, but are you sure it's 3ds $$anonymous$$ax FBX exporter not exporting, and not Unity ignoring weightless bones? Does the FBX format even support marking weightless objects as bones? Also, it's not about having "0" value vs "-" that makes it work. You can set it to 0.01, then change it to 0 and it's gonna stick, but still not gonna work. It has to do with the weight normalizer resetting the value, then you can even turn it into "-" and it's going to be included by Unity when building the avatar. But this approach is a mess. There are hundreds of different weights per item. Have you since found anything better?
No :( I didn't need to, though, because I came to realize that games requiring that kind of functionality are too big for me to handle alone.
Answer by prometheus_creations · Jun 24, 2017 at 09:37 AM
I used to have the same issue when exporting rigged clothes from 3ds Max to fbx in Second Life. The workaround was to open up the FBX file with a text editor, locate the bones list, and add in the missing bone names and bone count manually.
That's certainly another way to do it. I guess it's main advantage is that you can easily copy and paste the data over and over again into new files, and the disadvantage being that you have to manually input each bone name by hand once.
Can you share any resources on making these edits to the bone list in the FBX?
I can see multiple places where the bone names are listed in my FBX and they seem to be in the correct, hierarchical order