Search Unity

Transitioning in and out of ragdoll physics. How is this often done?

Discussion in 'Game Design' started by Nanako, May 27, 2015.

  1. Nanako

    Nanako

    Joined:
    Sep 24, 2014
    Posts:
    1,047
    I hope this will be a good forum for it, since my questions are more about design than specific technical issues.

    I've learned the basics of making ragdolls with rigidbodies, colliders and character joints, and i'm pretty good at making general characters with animators. Now i'm ready to try unifying these systems

    Our current plans call for the ability to turn ragdolling on and off at will, so that we can make a character collapse when desired, but also make them get up again and return control to animations. Ie, we won't just be using it on corpses

    I have a few ideas about how i might accomplish this:

    1. Keep a seperate ragdoll version of the character object, and swap it in for the normal one when desired. This seems like it would have a vast array of problems, such as script states and various changes not transitioning over without a whole lot of extra labour, i don't like this choice.

    2. Dynamically add and delete the appropriate components, when entering/leaving ragdoll mode. This would be rather complex since i'd have to save all of the component values, and it seems to me like the process of suddenly instantiating 20-100 physics oriented components(3 per bone) would be pretty performance intensive. But it does seem clean.

    3. Toggling the Enabled status on the components, to turn them on and off without having to contantly recdreate them. This sounded like the best idea until i actually took a look, and noticed that there is no enabled checkbox for rigidbodies or character joints. From which i logically deduce that disabling them isn't possible ? I could turn off the colliders, but i feel like having all those other components around constantly would cause some issues, especially since i only need them for a small fraction of the time

    Are there any other possibilities ? please say yes. give me advice D:
     
  2. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,859
    I've done that. It's been over a year (and a major Unity version) since I last fiddled with it, though. Give me a few moments to dig it up.
     
    Gigiwoo and Nanako like this.
  3. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,859
  4. Nanako

    Nanako

    Joined:
    Sep 24, 2014
    Posts:
    1,047
    well now, this is interesting. I'm reading that blog post, it seems to be mostly concerned with animation blending, which is a problem i hadn't even considered. It mentions a few issues with shortcomings of mecanim functionality, do you have any idea if some of those have been updated or improved?

    very nice demo, it's impressive ^_^
     
    Gigiwoo likes this.
  5. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,859
    The animation blending is important mainly when transitioning out of ragdoll mode, and back to a mecanim pose. You don't want to just snap back into pose, so you have to blend gradually from whatever pos the ragdoll has landed in, back to the pose determined by the animation system.

    And yeah, it does mention some complications at the time which have since been improved... but I'm sorry, I don't recall whether my latest version of the code took advantage of the improvements or not.
     
    Gigiwoo and Nanako like this.
  6. Nanako

    Nanako

    Joined:
    Sep 24, 2014
    Posts:
    1,047
    you are very awesome, thank you for the help ^-^ i'll poke through this thoroughly and see what i can turn up
     
    JoeStrout likes this.
  7. Gigiwoo

    Gigiwoo

    Joined:
    Mar 16, 2011
    Posts:
    2,981
    Manually controlling the blend between the animation states and the rag-doll is the standard way this is done. Kudos to @JoeStrout for his awesomely useful reply!

    Gigi
     
  8. ippdev

    ippdev

    Joined:
    Feb 7, 2010
    Posts:
    3,853
    Hmmm.. I tried this turning off the Animator/Mecanim component and my mesh disappeared. Was busy with a paying gig so I have not returned to it yet and was looking at a 90 dollar solution on the Asset Store. What did I miss that keeps my skinned mesh visible?..or is a Unity version bug??
     
  9. hopeful

    hopeful

    Joined:
    Nov 20, 2013
    Posts:
    5,686
    Some mecanim stuff gets fixed in 5.1, which is coming soon (tm).

    From what I've heard, we have maybe around 2 weeks before 5.1 launches.