From animation to ragdoll and back

Hello everyone,

following this tutorial I have an animated model that can turn into a ragdoll by setting isKinematic to false on all “bones” and disabling the animation. This works pretty much as intended.
While in ragdoll state I apply some force to it, so that it moves away from its original position.

Now I want to switch back to the animated model. But if I just set isKinematic = true and reenable the animator, the model is “teleported” to its original position instead of standing where the ragdoll ended up lying.

I already tried to assign the animator to an empty object of which the model is a child instead of applying the animator on the model directly, but this doesn’t change anything.


Edit:

I experimented a bit more. Even saving the new positions and applying them after turning on the animation does not help. The “bones” all lose their newly assigned position after the update call.

DerDot, I found the answer for the same problem in the following link:

It works just fine!

The only issue is with GameObjects that are child to your humanoid.

In my case, my character holds a sword, and falls to the ground still grasping it. But when he gets up (using any of both animations), the sword is out of his hand. It’s still a child of the hand, but it is offset. And, I don’t know why, the sword’s collider is no longer a trigger.

By the way, Perrttu, your script is awesome! Congratulations! And thank you for sharing it!

I just would really like to know how to solve this small problem.

There is basically just one solution to this need: dynamically create an animation/ animation state that your model uses to transition from the ragdoll position to the target animation position.
You basically use the ragdoll rest position as the starting keyframe of a per-bone animation that has your desired length of time, and targets a last keyframe which corresponds with the first frame of your target animation (i.e. get up).

Achieving this involves considerable knowledge of the technicalities of animations and mecanim, but it requires relatively few steps.