Search Unity

  1. We are migrating the Unity Forums to Unity Discussions by the end of July. Read our announcement for more information and let us know if you have any questions.
    Dismiss Notice
  2. Dismiss Notice

Going from ragdoll to animated model

Discussion in 'Animation' started by IbanCira, Sep 23, 2020.

  1. IbanCira

    IbanCira

    Joined:
    Aug 17, 2020
    Posts:
    1
    Hi, I hope this is the right category to post this. I'm trying to make a unit go into ragdoll and back. The going to ragdoll part is going well, I basically just followed this tutorial from Jason Weimann (
    ) but I'm having problems with the going back part.

    The tutorial suggests using two objects of the same rigged character, one being a ragdoll and the other one simply having the animator component (both being child objects of the character). For going into ragdoll mode, the ragdoll takes the current position and speed of the animated model, the animated model is disabled and the ragdoll enabled and off we go, that's my current setup.

    From what I could gather, what I should do to achieve the reverse, would be to slerp all the bones of the ragdoll into the standing up animation initial position and swap the ragdoll for the animated model. Sounds simple enough. The thing is that when the ragdoll is enabled and moves away from its original position, the animated model not only stays there, but it cannot be moved to the ragdoll's position by code, at least not while the animator component is enabled. And disabling it for moving the model is of no use, since once it's enabled, the model returns to it's original position (the last position the animator was enabled).

    Does anyone have any idea how to solve this? Or should I approach the whole ragdoll thing in a different way?

    Thanks for reading.
     
  2. DimitriX89

    DimitriX89

    Joined:
    Jun 3, 2015
    Posts:
    551
    I had some success at that using hack solutions. First, on moving the character controller by ragdoll: I remember having to detach the skeleton and character mesh from the root GameObject when the ragdoll is initiated; otherwise,trying to drive the root object by ragdoll bone will lead to dependency loop and the character will fly to hyperspace. Just remember to reattach skeleton back before Animator component is re-enabled. For animation blending out of ragdoll, I resorted to inverse kinematics instead of caching bone coordinates. I've converted the ragdoll bone coords into IK helpers' positions that best represent them. Then, while "getting up" animation was playing, I faded IK strength to zero
     
    radiantboy and DetaPlayFounder like this.
  3. radiantboy

    radiantboy

    Joined:
    Nov 21, 2012
    Posts:
    1,636
    Im looking at this right now, did anyone find any good resources for going from ragdoll back to animation ?
     
  4. zcxvbnm

    zcxvbnm

    Joined:
    Apr 25, 2021
    Posts:
    1
    I have this one project file which I found a year ago while struggling with the same problem as you. I actually found it on a very old thread dated back to 2013. This worked for me and sounds like this project file has the scripts that matches with your requests. So, in this file there are some script which handle the functionality. Firstly, it handles triggering the ragdoll part with a public bool which you can make true or false. Secondly, the same bool also triggers the ragdoll to standing up sequence where it gets the current ragdoll bones and aligns them with animator bones but you don't have to worry about using two character as this works by putting the script to a rigged character but you have to set up two animations. First, standing up from chest and second, standing up from back. So it just makes your character smoothly transition between ragdoll to anim and anim to ragdoll. I hope you understood what I said. If you did then please reply me that how it turned out. Anyways, here's a mediafire link as the file is too large - https://www.mediafire.com/file/mdlwldm60g7vrsv/RagdollTest.zip/file
     
  5. bugfinders

    bugfinders

    Joined:
    Jul 5, 2018
    Posts:
    2,212
    i may have the wrong end of the stick but puppetmaster (I think thats what its called) seems to do this, as it sync a ragdoll and will make the animations apply to it