• 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
0
Question by rageingnonsense · Sep 15, 2017 at 06:04 PM · bonesarmature

Bones work when manually adding object to scene, but not when instantiated in code; why?

So I have a simply mesh that is basically a cylinder, which has a spine of bones that each control a single edge ring in the mesh (a circle of vertices).

When I drag this object into the scene manually, I am able to play with the bones without any problem; the mesh moves as expected. However, once I instantiate it in code, only the first bone in the armature works; the others do absolutely nothing. If I change the root bone in the SkinnedMeshRenderer to one of the children, THEN that bone works, but none of the others.

The perplexing thing is that this did work without a problem before a code refactor, and now it no longer does. I have reduced my refactor down to simply instantiating the object to see if there is something I am doing afterwards that is breaking this, but it is STILL broken. In fact, when I manually drag my object in while the game is running; bones are broken there too. they only seem to work in edit mode.

Is my project corrupted? Anybody else have this problem? Any idea what I can do to fix this? I am using 2017.1.0p4

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

2 Replies

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

Answer by rageingnonsense · Sep 15, 2017 at 08:49 PM

As it turns out, I did not realize that if you pause the game in play mode, bones will not work correctly. If I refrained from pausing the game and then just moved the bones in the inspector, it turns out I could. I am not sure why pausing the game prevent bones from moving, but this tripped me up, because I was certain a different bug I was having was caused by this.

After being able to move the bones, I verified it was not the cause of the issue. Anyways, as far as this question is concerned, the TL;DR:

You cannot move bones in play mode with the game paused. They will not work correctly.

Comment
Add comment · 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
0

Answer by Bunny83 · Sep 15, 2017 at 08:44 PM

How does the hierarchy of your object look like? The "root bone" is only relevant for things like root motion. The actual link between the skinned mesh renderer and the individual bones is made by the [bones array of the skinned mesh renderer][1]. This array is not shown in the inspector. When you import a model that has a skinned mesh renderer, Unity assigns the bone gameobjects it creates automatically to that array.

When you instantiate such an object all object references to sub objects will be preserved during the instantiate. So as long as all bone objects are somehow a child of the model you instantiate everything should work just fine.

Also make sure you don't mark the object as "static" in the inspector. Is there any script attached to the object you drag into the scene?

It's difficult to help you with your problem since we can't see your object and setup.

Comment
Add comment · Show 1 · 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 rageingnonsense · Sep 15, 2017 at 08:46 PM 0
Share

As it turned out, for whatever reason, when I pawed the game and tried to manipulate the bones I no longer could. I found that if I refrained from pausing then I COULD. $$anonymous$$aybe I just ever did that before and didn't realize it. I feel quite silly.

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

69 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

Related Questions

How to deal with an extra spine bone? 1 Answer

Importing a armature from blender to unity ruins the models rotations -1 Answers

How can I make a certain bone rotate with the camera? 2 Answers

Make 3d model arm rotate with camera?? How to animate a particular bone/armature using script (eg. by rotation of the cameras Y Axis) 1 Answer

How to create hip and chest bones like the "dude" model has? 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