- Home /
Ignore past forces when isKinematic is set to false
My ragdoll seem to be affected by affected by the forces that were there before I actually activate it.
I have a number of characters controlled by an animator for most of the game, until, at some point they die. When it happens I deactivate the animator, and set their ragdoll.isKinematic to false. I'd like them to slowly and 'elegantly' fall down, but instead they get thrown violently across the scene. I understand this is a common problem (I could not find a solution to), and it seems to be related to how forces keep getting applied to the ragdoll, and when isKinematic is deactivated, they just act on the ragdoll all at the same time. Which makes sense, because if I activate my "Death" function as soon as I start the game up, they fall down nicely, exactly the way I'd like them to.
Any suggestion would be appreciated. I have already tried deactivating detectCollision until the ragdoll is activated, to call the ResetInertiaTensor function and to set all CollisionDetection to Continuous Dynamic, but they don't seem to do anything or (in the case of changing the collisionDetection anddetectCollision) make things worse.
Here's my "death" function, for reference, where "boneRig" is the Component array of all the rigidbody components in the object.
public void Death()
{
GetComponent<Animator>().enabled = false;
foreach (Rigidbody ragdoll in boneRig) {
ragdoll.isKinematic = false;
}
}
Answer by Bunny83 · Jul 25, 2018 at 04:50 PM
Make sure your seperate "limbs" do not collide with each other. So put them on a seperate layer and deactivate collisions within that layer. Also make sure that if the whole character has a collider / charactercontroller you have to deactivate / remove those. Otherwise your seperate rigidbodies would overlap and get seperation forces applied. That's also the reason why you want to deactivate collisions between the rigidbodies.
Thanks, although it doesn't seem to solve the problem. It stills falls down quite normally is Death() is activated right away, and gets thrown away if I wait until Death() actually has to be activated.
It's still quite useful, though. I've been only testing with T Pose for now, where the rigidbodies of the limbs not collide anyway, but I would have run in that problem once I start animating.