- Home /
Changing mesh on SkinnedMeshRenderer causes deformation
Hello there, i am trying to change the pants on my character by swapping the mesh and materials on the skinned meshrenderer.
I'm swapping from short pants to long pants but unfortunately the mesh gets deformated:
SkinnedMeshRenderer skinnedMeshRen = e.chest.GetComponent<SkinnedMeshRenderer>();
SkinnedMeshRenderer newMeshRenderer = ...code to get new meshrenderer on new pants from resources
skinnedMeshRen.sharedMesh = newMeshRenderer.sharedMesh;
skinnedMeshRen.sharedMaterials = newMeshRenderer.sharedMaterials;
Transform[] childrens = e.rootBone.GetComponentsInChildren<Transform>(true);
Transform[] bones = new Transform[newMeshRenderer.bones.Length];
skinnedMeshRen.bones = bones;
The file is in .fbx format and both pants are skinned to the same rig.
Thank you :)
Did you find a fix yet? We have the same problem and it only occurs with some meshes, but i couldn't find a pattern yet. Thanks!
Answer by theANMATOR2b · Sep 26, 2017 at 06:37 PM
I don't understand your code - I'm an animator.
Why not instead just hide/unhide via turning on/off the skinned mesh renderer of each pair of pants?
They are separate mesh objects even though they are rigged/skinned to the same skeleton right?
Thank you for the response but every character model with 50 clothing types as child is not an option for us. You are right for sure, this is the easiest way but that's not what i'm looking for :)
Thank you anyway! :)