I have two fighters. One kicks the other one in the head and the other one drops to the floor like a ragdoll.
The set up so far is - the character is fully set up as a ragdoll but is actually being controlled by the animator - thus preventing the ragdoll from happening.
The idea is to flip the switch in code and remove the animator component and thus release the ragdoll.
This actually works, but only half the time.
When the ragdoll is triggered, half the time he drops as you would expect, but the other half of the time its like some invisible Monty Python foot has stomped him into the ground crushing him with ridiculous force. Sometimes this pushes him through the ground plane where he gets trapped and flails around for a bit before the physics launch him into the air.
Why does this happen and how can I prevent it? It’s frustrating because it actually works fine the rest of the time.
Solved my own problem within fifteen minutes of posting this. Sometimes the act of asking the question sparks new ideas for solutions!
I’ll write this here anyway so anyone else with a similar issue can use it.
I was playing around with the ragdoll and the animator. I noticed that turning the ragdoll off straight away (after pressing play) resulted in a fairly smooth ragdoll effect. The longer I waited before activating the ragdoll the more insane the reaction.
We figured out that perhaps the rigidbodies - being active from the start but repressed by the animator - were somehow storing energy as they constantly tried to calculate where they should be going without actually being allowed to go there.
I wrote a foreach loop which would make all the rigidbodies kinematic at the start, then make remove the kinematicness (that’s a word I made up) when he gets kicked. This allows the rigidbodies to calculate a nice clean simulation the moment the animator is turned off.