• 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 Ananta · Jul 06, 2011 at 02:21 AM · animationcharacterbonelateupdateorder-of-execution

How to play character animation after bone deparent?

For a certain reason, I want to take apart a character's bones separately(a bone will have no parent and no child).

However, before an animation is advanced, bone structure is needed to be restored.

So referred to Unity execution order (http://unity3d.com/support/documentation/Manual/Execution%20Order.html ), my code is like this.

 void Update()
 {
     ParentAllBones();
 }
 
 //animations are advanced...

 void LateUpdate()
 {
     DeparentAllBones();
     //execute some process
 }
 
 //rendering
 
 /*
 void ParentBone()
 {
     child.parent = parent;
 }

 void DeparentBone()
 {
     child.parent = null;
 }
 */

But the animation isn't played. Where do I make mistakes? How can I separate bones and play character's animation?

Comment
Add comment · Show 4
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 Waz · Jul 06, 2011 at 10:11 PM 0
Share

I think you should explain why you think you need to bust up the hierarchy, because not doing that may be the simplest answer to your question. I certainly wouldn't be surprised if animations never worked again if you broke up the hierarchy!

avatar image Ananta · Jul 07, 2011 at 12:08 AM 0
Share

$$anonymous$$y purpose is scaling character's bone, the same as this question (http://answers.unity3d.com/questions/137667/scaling-widthheight-of-a-characters-headbody.html ). And thanks to your former answer I nearly achieved my end. But I think that "Is the hierarchy the root of all evil?", so for an experiment I broke up the hierarchy.

avatar image Waz · Jul 07, 2011 at 02:41 AM 0
Share

I think I see what you're trying to do. Why don't you just reparent them immediately after doing "some process"? What are you hoping will happen in between the LateUpdate and next Update that you think leaving them deparented will help? Certainly rendering isn't going to be different because of the deparenting. The animation will fail if the hierarchy is not there when it is sampled, since it is defined using transform paths that correspond to the hierarchy.

avatar image Waz · Jul 07, 2011 at 02:51 AM 0
Share

Experimenting is good of course, but this seems to be getting far more expensive than just adding more bones. Why do you have a strict bone limit? No way will an extra tummy bone or such be anywhere near as expensive as any deparenting and reparenting process.

2 Replies

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

Answer by sneftel · Jul 11, 2011 at 01:43 PM

The constant parenting and deparenting may end up being a huge hit to performance -- not necessarily, but I'd stress test that early on, just to be careful. The basic issue with animations not playing is likely due to the base Animation component's references being invalidated. It's sort of a fragile component with respect to hierarchy changes.

In any case, flattening the hierarchy is NOT going to help you with your scale->skew issues, so don't waste your time on it. I'll explain in more detail on that question.

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 Paulius-Liekis · Jul 11, 2011 at 12:55 PM

I can't really remember if this should work (it depends on when animation tracks are rebound to transforms).

You could do this by having secondary skeleton (which is deparented) and then you would copy desired world-pose transforms from parented (invisible, but animated) skeleton.

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

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

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Animations: just making sure my workflow is right. 1 Answer

Allow translation data on joints other then the root? 0 Answers

animation.Play not affect specific bone 1 Answer

Is there a limit to the number of bones in a model 2 Answers

AnimationState.AddMixingTransform 1 Answer

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges