Search Unity

Character pick up Ragdoll

Discussion in 'Physics' started by Der_Kevin, Oct 28, 2015.

  1. Der_Kevin

    Der_Kevin

    Joined:
    Jan 2, 2013
    Posts:
    517
    Hey! I need some help from you guys :)

    so i want that my character can pull/pick up a Ragdoll around, that means grabbing his head, arm, foot, whatever and pull it around like a pillow. at the moment things look like this:

    ezgif.com-optimize.gif

    so, i have a player, and a ragdoll. but how can achive the stuff i describet before?
    by the way, iam using a gamepad, so please dont involve a mouse pointer in the solution :) also keep in mind that there can be more than 1 ragdoll in the gamescene

    the problem iam facing are:
    - how do i move my hand to the hand of the ragdoll for example? (iam owning FinalIK by the way if that helps)
    - how do i stick the hand from the ragdoll which iam grabbing to the hand of my character?
    - and how to do this dynamicly with several ragdolls and then only grabbing the nearest/reachable ragdoll?
    thanks!
     
    Last edited: Oct 28, 2015
  2. Kona

    Kona

    Joined:
    Oct 13, 2010
    Posts:
    208
    I believe there's a class in the Unity Standard Assets package called "DragRigidbody" which does pretty much what you want to achieve. By modifying that slightly you should be able to achieve what you're aiming at.

    I would probably call Physics.OverlapSphere to see if there are any ragdolls infront of the player, from there you can check the distance to each ragdoll and select the one closest to the player.
    Next you could set an array in whatever class you create / modify to allow the draging of the ragdoll, and fill the array with every rigidbody of the target ragdoll that should be acting as an "anchor point" or a limb the player can grab hold of, then on interaction you'ld check the distance to each of those rigidbodies position and the player, once again select the closest one.

    As far as I recall the DragRigidbodies code used a character joint component or something like that, so sticking it to the players hand should be no problem, just set position of the dragged rigidbody to the players hand and assign joint to be linked with. :)
     
    UnityUser9860 likes this.