Search Unity

  1. Improved Prefab workflow (includes Nested Prefabs!), 2D isometric Tilemap and more! Get the 2018.3 Beta now.
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. Let us know a bit about your interests, and if you'd like to become more directly involved. Take our survey!
    Dismiss Notice
  4. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice
  5. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

Ragdoll flies out of parent when exploding, how to make it follow along?

Discussion in 'Physics' started by nicmarxp, May 13, 2018.

  1. nicmarxp

    nicmarxp

    Joined:
    Dec 3, 2017
    Posts:
    137
    I'm having ragdolls that fly when a grenade explodes, but they are flying out of it's parent, and I'm not sure how to avoid that, since I want them to get up again after flying away transitioning back with a get-up-animation.

    I might have a weird setup, but my structure looks like this:

    Unit (Scripts, NavMeshAgent, Animator for FSM)
    - ModelContainer (Animator)
    -- Bip001 (Container for all bones)
    --- Bip001_Pelvis (Rigidbody, Collider, Configurable Joint, Fixed joint -> connected to RagdollPuller)
    ---- All other body parts as normal children (Rigidbody, Collider, Configurable Joint)
    -- Mesh (Skinned mesh renderer)
    - RagdollPuller (Rigidbody, connected to Bip001_Pelvis with a Fixed joint)
    - HealthBar (Graphic)

    When an explosion happens, it's applied to RagdollPuller, and it nicely makes the ragdoll fly, however, since it's a child of Unit, the Unit stays in place, and when I disable the ragdoll, they snap back into it's original position.

    I first tried to have the Rigidbody and Fixed joint on the main gameobject (Unit), but that made them spin around like crazy.

    How would you setup a situation like this, to make it work in a better way?

    You can see what's happening since their health bars don't follow along:


    PS: I have bought the PuppetMaster asset, but since I will be animating around 50 characters in a scene, I figured it might use too much resources for this. If you've used Puppetmaster on a mobile application with good performance, please let me know.
     
  2. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    4,691
    maybe some ideas for the bars
    - healthbars under head in hierarchy, and then use script or shader to keep them facing camera (and above head)
    - external script to move healthbars on head positions in the view (so they dont need to be child of unit either)
     
  3. nicmarxp

    nicmarxp

    Joined:
    Dec 3, 2017
    Posts:
    137
    Thanks, there was a billboard script for it but it’s disabled :)

    I think the solution is to have the ragdoll as the root object and put the scripts a level down, and the ragdoll-mover-object as a separate object. Not sure but will test again.. :)