• 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
9
Question by maxnorth · Jan 26, 2015 at 09:28 AM · ragdoll

Smoothly transition between animation and ragdoll

I've looked around and I can't find a solution to this problem. I want to have an animated character become subject to the effects of the attached rigidbodies when some condition is met, but I can't create a nice effect. One solution I found online suggested collecting all rigidbodies into an array with GetComponents() and then for each-ing rigidbody.enabled or rigidbody.usegravity to true, but this doesn't make sense to me because animations are over-riding the effects of the rigidbodies on the limbs. Whether they are enabled or disabled makes no difference as long as an animator controller is active, in my experience.

I have tried disabling the animator component on the ragdoll character, but when I do this the ragdoll immediately twists and slams down into the ground beyond what gravity should be applying (this is definitely not due to any physics settings or how gravity is being applied to the model... once the ragdoll settles after a second it responds 100% normally to all forces). Additionally the model is typically deformed by the last animation pose, even leaving open holes in the models (which I can't make sense of... shouldn't the texture be stretching?). My main concern is to have a very smooth transition that creates the effect that the character is collapsing or fainting naturally out of their last pose.

I came across this video which seems to accomplish that affect perfectly, and it does so by creating an animation state in the animator controller that has no animation clip. When they transition to that state the ragdoll takes over very fluidly and the character collapses (you can skip to 7:00 in the video to see what he does and the effect). When I tried transitioning to a state without an animation clip my character took on the pose it has during the muscle configuration screen within the avatar maker rather than become a ragdoll.

I've seen some assets in the asset store that seem to be directed at this kind of thing, but I'm wondering if there's a simple solution I should be aware of first, such as in the video above. I'm also vaguely aware of the idea of deleting the animated character and instantiating a ragdoll with the same bone transforms as the animated character last had, but that video has me thinking that there must be simpler solutions.

Thanks in advance for the help (and thanks for reading all of that)!

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 sniper43 · Jan 26, 2015 at 11:22 AM 0
Share

Do not animate positions. Animate rotations and have them apply form joints. But even this prevents smooth rigidbodying.

If you really want a ragdoll, DISABLE all animation along when enabling gravity. You could this by disabling the animator controller on all children.

A ragdoll is after all something you want ot happen naturally.

2 Replies

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

Answer by maxnorth · Jan 26, 2015 at 01:12 PM

It took a while for this question to finally go up but I learned a lot in that time and solved my problem. The number one thing that was causing problems was the fact that if the rigidbodies are not set to isKinematic while an animator is controlling the character, then every single force that gets applied to those rigidbodies during all that time stacks until the animator is removed or disabled, at which point they are all applied simultaneously, which is why gravity slams down my character for just a moment and then acts normally. This occurred to me after I was shooting the character while it was animated, because the force of each bullet would apply when I deactivated the Animator. My current solution is to put a single animator on the top layer and use "foreach ( Rigidbody rb in GetComponentsInChildren<Rigidbody>() ) rb.isKinematic = //false or true" at the same time that I set "GetComponent<Animator>().isEnabled = //false or true", and this creates the exact effect I've been aiming for.

Just for the sake of spelling things out, I'll also add that I realized why the tutorial in the video I posted above worked but wouldn't for me. They were using legacy animations and I was using humanoid. If an Animator controller intended for a humanoid avatar has any states with non-human type animations or no clip at all, then the player automatically goes into that static muscle configuration screen pose.

Comment
Add comment · Show 5 · 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 reiti.net · Nov 16, 2015 at 01:27 PM 0
Share

After 2 days of searching why my ragdoll gets slammed into the ground after disabling the animator I finally found your information about the stacking forces (THAN$$anonymous$$ YOU!)

In my case I am using a Rigidbody+CapsuleCollider for the Animator Stuff and also have RagDoll-specific Colliders+RigidBodys. Ragdoll-Colliders gets disabled in Start(). When the Character dies, I disable the animator and the capsule-collider of the base-model and re-enable the colliders for the ragdoll.

Because the character can naturally fall down/jump the kinematics on the main-rigidbody are turned OFF, while those of the ragdoll colliders need to be turned ON to not have stacking gravity forces. Turned out, THIS was my problem and erading your answer gave me the required hint.

avatar image nicmarxp · Feb 12, 2018 at 06:33 PM 0
Share

It might be a version thing, but GetComponent().enabled = true/false works for me, not isEnabled. Thanks though! :)

avatar image roshanjafri31_unity · Mar 23, 2019 at 01:37 PM 0
Share

Thanks a lot!! very valuable information. :)

avatar image schkorpio · Sep 08, 2020 at 08:30 AM 0
Share

life saver - THANKS :-)

avatar image deadbobgames · Dec 08, 2020 at 06:45 PM 0
Share

Same issue, and the solution worked for me as well. Thank you for taking time to post this answer / issue.

avatar image
2

Answer by unity-huunity · Jan 26, 2015 at 01:55 PM

Check out this http://perttuh.blogspot.fi/2013/10/unity-mecanim-and-ragdolls.html

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 Koreldan · Jul 29, 2016 at 07:17 PM 0
Share

Finally ! thx man

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

12 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

Related Questions

Ragdoll IsKinetic doesn't work 0 Answers

how to connect ragdoll character to an object ? 1 Answer

Why do both Ragdoll and Animator are working at the same time ? 1 Answer

Configurable joint axis aren't working with local space 0 Answers

How to easily create a ragdoll with configurable joints? 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