Search Unity

Skinned Animation + Skinned Ragdoll?

Discussion in 'Editor & General Support' started by TheUltimateJosh, Dec 28, 2009.

  1. TheUltimateJosh

    TheUltimateJosh

    Joined:
    Dec 7, 2009
    Posts:
    32
    Well, basically, I'd like to animate parts of my character via physics while animating the rest via an animation imported from 3dsMax.

    I've got them both working, just not at the same time, and I'm wondering if I can toggle animation for certain bones.
     
  2. TheUltimateJosh

    TheUltimateJosh

    Joined:
    Dec 7, 2009
    Posts:
    32
    Would this happen to be one of those really easy things that I seem to be unable to find in the documentation, or did I just ask at a bad time?
     
  3. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    Its one of those completely not easy things actually.

    The following things could serve as an idea but they are untested:

    1. Check out how the locomotion system (available on the unity website) handles it

    2. Look into using blend animations. normal animations are "enforced" so if their animation says that the bone rotates by 30 degrees and ends in a state X it will do that, physics will not have any way to influence it.
    Blend animations should add their effect on top of the regular animation, but I'm unsure if that regular animation could be an animation or ragdoll

    3. Apply the stored animation physically by parsing and processing the data.
     
  4. TheUltimateJosh

    TheUltimateJosh

    Joined:
    Dec 7, 2009
    Posts:
    32
    Well, I think you just gave me an idea on how to do it, actually. I'll check it out tonight.
     
  5. TheUltimateJosh

    TheUltimateJosh

    Joined:
    Dec 7, 2009
    Posts:
    32
    Well, the magic is found.

    The method is AnimationState.AddMixingTransform(...)...

    http://unity3d.com/support/documentation/ScriptReference/AnimationState.AddMixingTransform.html

    I think it may be helpful to mention that the method sets the mixing transform to only what is specified.

    By using this, one can put rag doll parts on an animated skinned mesh, which may be useful for parts such as hair or boobs.

    For example, what I did.

    I wanted the tail on my character to use a rag doll animation. I took the running animation and applied it to four parts of the character: the center of gravity, the hip bone, the legs and children, and the spine and children. Since the both the legs and tail are children of the hip bone, applying the mixing separately becomes necessary. Anyways, I gave the tail bones a physical presence, rigid bodies, joints, and such. Since the tail is not included in the animation, it is free to act physical. Adding a rigid body to the hip that the tail is connected to allows the tail to swing along with the animation of the hips swaying.

    I thought it might be useful.

    Taking this info, one could apply this to hair or other 'free moving' body parts. It could be very interesting to see part of a character go limp when shot. However, having a death animation blend to a rag doll I still don't think is possible. Not possible unless someone can find a way to take the derivative of a animation curve and have it work correctly for rotations, since additive animations are the only ones I've been able to blend with physics simulations.