• 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 /
  • Help Room /
avatar image
0
Question by Skatty · Oct 07, 2022 at 04:07 PM · riggingskinnedmeshrendereritemequip

How does Skinned Mesh Renderer exactly works? Problems with changing player model

Hi, So I have t$$anonymous$$s MMORPG project and I'm using a character from the Brackeys RPG tutorial*(picture) I have a blend file for it for adding items to the rig and I'm using my own Animation Controller (TESTOWY)(picture). Default items are working fine in the game (picture) So to add a new item for example an armor, I use blend file of armor and just connect it with the skeleton used for the same player model (not$$anonymous$$ng else in the armor .blend file -> only skeleton and armor).(picture)*

What I do next is: 1. Import .FBX file of the rigged armor to the Unity. 2. Drag and drop it into the scene. 3. Unpack it, drag and drop my armor SkinnedMeshRenderer into the Inspector to keep it as an Equipment/Item mesh. Later I add t$$anonymous$$s mesh to my item w$$anonymous$$ch equiping is working fine in the game also with animations. (picture) alt text But t$$anonymous$$s model is using 1 SkinnedMeshRenderer (Body) as a target for equiping. SO today I downloaded a new model w$$anonymous$$ch I would like to use. FREE RPG CHAR. I just Drag and Dropped character .Prefab into my player prefab to REPLACE GFX and also use TESTOWY controller. In the game animations are perfect. I downloaded their Plugin to Transfer SMR w$$anonymous$$ch is working nice in the inspector - I use character prefab, and items Mesh Model (not prefab), it's getting applied on the character and animations are working. (picture)So I drag and drop the converterd SMR into the inspector but it's not working when being applied to the Equipment. Because t$$anonymous$$s model is cut into separated body parts and many SkinnedMeshRenderers, I changed my code and Equipped items are being stretched etc (picture). alt text

I understand maybe bones data is being lost when saving SMR of the Armor - ok then. So I add the downloaded character model into my .blend skeleton of the previous model and its working too in the engine but armor is still not working. Even with the old code and ALTHOUGH it was connected TO THE SAME RIG AS THE BODY?! It's fine when in the same blend file I add the armor ONCE AGAIN into the Skeleton. Why it's not working? Same skeleton for the item and body but it's not being applied properly? How does it all work? Here is my code for equiping:

     SkinnedMeshRenderer newMesh = Instantiate<SkinnedMeshRenderer>(newItem.itemMesh);
 
    newMesh.transform.parent = targetMesh.transform;
    newMesh.bones = targetMesh.bones;
     newMesh.rootBone = targetMesh.rootBone;
 
 CODE BELOW IS USED FOR THE NEW MODEL (apply to different targets)
    switch ((int)newItem.equipSlot)
      {
          case 0:
          newMesh.transform.parent = headTargetMesh.transform;
              newMesh.rootBone = headRootBone;
              newMesh.bones = headTargetMesh.bones;
 
          break;
 
          case 1:
              newMesh.transform.parent = bodyTargetMesh.transform;
              newMesh.bones = bodyTargetMesh.bones;
              newMesh.rootBone = bodyRootBone;
 
             break;
 
         case 2:
         newMesh.transform.parent = legsTargetMesh.transform;
         newMesh.rootBone = legsRootBone;
              newMesh.bones = legsTargetMesh.bones;
              break;
 
          case 5:
          newMesh.transform.parent = feetTargetMesh.transform;
          newMesh.rootBone = feetRootBone;
          newMesh.bones = feetTargetMesh.bones;
          break;


bb.jpg (414.1 kB)
aa.jpg (318.9 kB)
Comment
Add comment
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

0 Replies

· Add your reply
  • Sort: 

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

192 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 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 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

Problem when changing mesh to SkinnedMeshRenderer 0 Answers

How to swap Rig at runtime? 0 Answers

Unity (rigged) clothes to a character 1 Answer

Strange issue with scriptable objects in the "Create" menu 0 Answers

how to use a Mocap FBX of a full skeletal rig to animate fps hands? 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