Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Dragging or Hanging Ragdoll

Discussion in 'Animation' started by codypersinger, Oct 20, 2018.

  1. codypersinger

    codypersinger

    Joined:
    Dec 5, 2016
    Posts:
    2
    Hello all, I'm trying to figure out how to attach ragdoll limbs to a point in space. Specifically I'd like my player ragdoll to hang from a ledge by his hands. I'm going to provide fairly exhaustive info on what I have setup so please bear with me.

    My player GameObject has an Animator driven via a script "PlayerAnimation". This Animator also has a controller that makes use of IK via a script "PlayerIK". The player GameObject also has a CharacterController that is driven via a script "PlayerController".

    The player GameObject also has several child GameObjects, but most importantly the "Body" GameObject contains the root of the Ragdoll. I configured the Ragdoll in the Ragdoll Wizard, with the Hips as the root and a Mass of 70. The Ragoll is disabled (is kinematic) until I activate it in the PlayerController script. I'm using Physics.IgnoreLayerCollision to avoid issues with CharacterController collider and Ragdoll colliders. Note that the wizard did not add Rigidbody and CharacterJoint components to the Hands, but the Rigidbodies of each Forearm cover the Hands, see image:

    IMAGE: Player Ragdoll - imgur

    IMAGE: GameObject Heirarchy - imgur

    IMAGE: Inspector Info - imgur

    When the player jumps, I raycast to find a grab-able ledge. If found, I immediately activate IK for the Hands, set the IK position to the point on the ledge, and set the weight to 1 (will interpolate later once everything is working properly). I also play a "dangling from ledge" animation. This works decently, except that the player's arms are not fully extended like they would be if you had caught yourself on a ledge - instead they're bent like doing a pull-up, see image:

    IMAGE: Hanging from Ledge - imgur

    I've tried to solve this issue with IK Hints for the Elbows, and that has helped - but I think the primary issue is the player's Y position in space. I could lower the player with CharacterController.Move, but I think this would all look more realistic if I could simply transition into the Ragdoll state, once the Hand IK position is set, so that the Ragdoll dangles from the hands somehow. I've tried adding Rigidbodies and different types of Joint components to the Hands via script once the IK position is set, but obviously transitioning to Rigidbody state requires disabling the Animator component so IK will no longer be active...

    But the REAL issue is that I just can't figure out how to get the Ragdoll Hands onto the ledge, and the rest of the Ragdoll dangling from them. It seems like the gravity force is possibly breaking the Joints or something similar. I've tried various combinations of setting the Hands Transform or Rigidbody position and Joint component anchor vector via script, but no matter what I've tried, I can't seem to just attach the Ragdoll hands in space such that the rest of the body swings/dangles from them. In my research, it seems that a SpringJoint in similar scripts which allow Rigidbodies to be dragged, but I'm not sure how that should translate into an entire Ragdoll being dragged by one of the child-most GameObjects...
     
    wavekeyboard likes this.
  2. dibdab

    dibdab

    Joined:
    Jul 5, 2011
    Posts:
    976
    you probably already know, but

    you need to use fixed joint (add as connected body to character joint)
     
    wavekeyboard likes this.