Eject Overlapping Bodies Without velocity

I’m working on a ragdoll system when a character dies.

If I turn off a rigidbody’s isKinematic property when it’s already penetrating geo, the body is ejected with velocity from the geo. Obviously, I do want the collision to be solved, but I’d rather the rigidbody be placed nicely outside of the geo rather than flinging it out. Can this be accomplished?

Do you mean “turn off isKinematic”? A rigidbody ignore physics when isKinematic is true, and return to physics control when it’s set to false.

Anyway, the problem you’ve mentioned is probably the “penetration penalty force”, a repulsion force applied to the penetrating rigidbody.

You could use a simple script to limit the rigidbody velocity:

var limVel = 0.1;

function FixedUpdate () {
  if (!rigidbody.isKinematic){
    rigidbody.velocity = Vector3.ClampMagnitude(rigidbody.velocity, limVel);
  }
}

You can set limVel to some high value (say, 100) to disable the velocity limit, if you want to restore regular behaviour.

Haven’t tried it, but maybe you could catch this with OnCollisionExit()?