Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
5
Question by Dorumeka · Nov 26, 2017 at 04:58 PM · bonesskinnedmeshrendererskinned mesh rendererclothes

Is it possible to update a skinned mesh renderer's bones?

I have a model with nested game objects that have skinned mesh renderers that are linked to that model's bone hierarchy. This nested objects are its clothing, so when the model moves, its clothes deforms with it accordingly. I'm trying to add new clothes to it, but they don't deform at all.

I'm thinking that maybe I shouldn't link a picture of the entire model, as it is kind of NSFW, so here are some pictures of the clothing item in question.

alt text

To the left is the default boot which I imported together with the complete model. To the right is the new boot that I imported with the very same complete model, but at a later time.

alt text

Here is how this new boot deforms when its entire model is added to the scene.

alt text

This is what happens when I try to attach this game object to another model.

alt text

Even though I changed this new item's Root Bone property's, it's still not linking itself with the other model's bones.

The model which I'm trying to nest this new boot is my main prefab that has much work done to it (ragdoll, hitboxes, tags, custom scripts that use specific bones, etc). The only thing that seems I can do is to recreate this prefab again, with the new model this time. That is very inefficient for me, as I have a lot of prefabs that would need to be created all over again. Looking through the documentation is not yielding answers to this, neither googling for this. How do you nest new skinned mesh renderers to game object and link its bones to it?

Edit: Issue solved. As I'm not skilled enough as a programmer to make a script of my own without scratching my head for hours, I grabbed the one linked by Cherno. The formatting was a little messed in the post, so I took the liberty to fix it and put it on a pastebin: https://pastebin.com/RVY8ygur.

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image david-mal · Jan 31, 2020 at 04:40 PM 0
Share

Thank you for providing this code snippet! It' s awesome <3

1 Reply

· Add your reply
  • Sort: 
avatar image
7
Best Answer

Answer by Bunny83 · Nov 26, 2017 at 05:57 PM

The rootbone has nothing to do with the actual skinning of the SkinnedMeshRenderer, It has been added for the root motion feature of the the mecanim system.


The actual link between the bones and the SkinnedMeshRenderer is made through the bones array. However this array is not visible in the inspector though it is serialized. That's why a SkinnedMeshRenderer does not animate when you delete it's own bone array.


One problem is that if you have two skinned meshes with identical bones, it's not necessarily given that the order is the same. If it is the same you could simply copy the bones array from your main model to your clothes model.


If the order is not the same and you want to use a single bone structure you would need to keep the both bone hierarchies and use a script to replace the bones one-by-one based on the bone name / hierarchical position.

Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Bunny83 · Nov 26, 2017 at 06:29 PM 1
Share

Note that when you import a Skinned$$anonymous$$esh the mesh itself (not the skinnedmeshrenderer) has a bindposes array. Those define the actual relative bone positions in their bind pose / reference pose. Each element of the bones array corresponds to the same element in the bindposes array. Further more each vertex of the mesh has a BoneWeight. Each "boneIndex" refers to one element in the bones array. This is the whole magic behind the linking between the $$anonymous$$esh and it's bones.

avatar image Cherno · Nov 26, 2017 at 09:42 PM 2
Share

I suppose this might help you: Shared skeleton and animation state

avatar image Dorumeka · Nov 27, 2017 at 09:39 AM 0
Share

Thank you so much guys for the quality answers, you are life savers. I'll edit the original post with a clear note for the solution.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

74 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Combine Skinned meshes 2 Answers

Bones do not switch when called for (Find bones of player then replace clothes bones) 1 Answer

Does the transform.parent hierarchy have any relationship to the bone hierarchy? 1 Answer

New material only covering the same area as the previous one 1 Answer

Attach one animated mesh to another 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges