Search Unity

gradually freezing ragdoll after it's come to rest

Discussion in 'Physics' started by jchowdown-asla, Aug 14, 2017.

  1. jchowdown-asla

    jchowdown-asla

    Joined:
    May 10, 2017
    Posts:
    26
    Hi,

    Right now our characters ragdoll nicely onto the ground but a lot of the time, parts of their body don't ever stop swaying after the rest of the body has collapsed onto the ground. For example a character with a big torso might land in a way that leaves its head dangling from the neck, and the head sways back and forth. Our dead characters stay onscreen for quite a long time and we'd like to remove this movement from the game.

    I looked at trying to fine tune the Drag and Angular Drag values of all the rigidbodies on the character but:
    a) values that are too high affect the actual ragdoll simulation (slowing it down, sad!)
    b) values that are too low don't slow down the unit enough after the unit has come to rest on the ground (doesn't fix my problem, also sad!)

    I'm thinking about adding a timer so that X seconds after the initial AddForceAtPosition, I write some FixedUpdate() code that gradually adds a small delta (say 5 per second) to the Drag and Angular Drag, for another Z seconds, after which I just freeze all position/rotations. Does this sound OK to everyone?

    I *could* add constraints immediately after the X-second timer but the sudden stop in motion will look too abrupt if there's a lot of residual motion.