Search Unity

Smoothly going from ragdoll to animator animation

Discussion in 'Animation' started by stphnhffmnn, Sep 7, 2016.

  1. stphnhffmnn

    stphnhffmnn

    Joined:
    Dec 21, 2015
    Posts:
    3
    So I am trying to do something not to overly complicated but can't seem to get the last step down.

    Write now I can use the animator and character joints to go from an animation to ragdoll and back to animation.

    The problem is the last step ragdoll -> animation has no smoothness whats so ever. I believe the problem comes from running stopping the animator and restarting it. When it restarts it seems to refresh bone positions,

    I have tried using layers and masks. Setting the animator to a empty state on a mask with zero bones activated and setting the weights on the actual animation layers to 0.

    any suggestions or is this just an animator issue?

    some of the code after messing with masks

    Code (CSharp):
    1.  if(!ragActive && !standingBackUp) //
    2.         {
    3.             anim.SetLayerWeight(0, 0);
    4.             anim.SetLayerWeight(1, 100);
    5.             foreach (Rigidbody bodies in GetComponentsInChildren<Rigidbody>())
    6.             {
    7.                 bodies.isKinematic= true;
    8.             }
    9.             foreach (Collider coll in GetComponentsInChildren<Collider>())
    10.             {
    11.                 coll.isTrigger = true;
    12.             }
    13.             if (Input.GetKey(KeyCode.C))
    14.             anim.CrossFade("creature1Idle", 0.5f);
    15.         }
    16.         else if(ragActive && !standingBackUp)
    17.         {
    18.             if (!timerGoing)
    19.             //{ StartCoroutine("Restand"); }
    20.             anim.SetLayerWeight(0, 0);
    21.             anim.SetLayerWeight(1, 0);
    22.            
    23.             foreach (Rigidbody bodies in GetComponentsInChildren<Rigidbody>())
    24.             {
    25.                 bodies.isKinematic = false;
    26.             }
    27.             foreach (Collider coll in GetComponentsInChildren<Collider>())
    28.             {
    29.                 coll.isTrigger = false;
    30.             }
    31.         }
     
  2. stphnhffmnn

    stphnhffmnn

    Joined:
    Dec 21, 2015
    Posts:
    3
    Code that works expect for the going back to idle part, where it jerks. Which i still feel like is a problem with the animator.enable = true/false

    Code (CSharp):
    1.         if(!ragActive && !standingBackUp) //
    2.         {
    3.             anim.enabled = true;
    4.             foreach (Rigidbody bodies in GetComponentsInChildren<Rigidbody>())
    5.             {
    6.                 bodies.isKinematic= true;
    7.             }
    8.             foreach (Collider coll in GetComponentsInChildren<Collider>())
    9.             {
    10.                 coll.isTrigger = true;
    11.             }
    12.             if (Input.GetKey(KeyCode.C)) { }
    13.            anim.CrossFade("creature1Idle", 0.5f);
    14.         }
    15.         else if(ragActive && !standingBackUp)
    16.         {
    17.  
    18.             anim.enabled = false;
    19.            
    20.             if (!timerGoing)
    21.             { StartCoroutine("Restand"); }
    22.            
    23.             foreach (Rigidbody bodies in GetComponentsInChildren<Rigidbody>())
    24.             {
    25.                 bodies.isKinematic = false;
    26.             }
    27.             foreach (Collider coll in GetComponentsInChildren<Collider>())
    28.             {
    29.                 coll.isTrigger = false;
    30.             }
    31.         }
     
  3. stphnhffmnn

    stphnhffmnn

    Joined:
    Dec 21, 2015
    Posts:
    3
    ksf000 likes this.