- Home /
Character Controller Force Issue (With Ragdoll)
Hi!
I've got a character who I'm controlling with the aptly named Character Controller. The character also has a rig, and several animations, which our modeler and animator so kindly provided me. Since I want the character's death to feel realistic, I created and attached a Ragdoll to it (which is nothing more than Rigidbodies, Colliders, and Joints).
Since I don't have much idea, in order to "kill" my character, I just deactivate its Animator, and gravity does the rest. The problem is that the Character Controller seems to be applying some force on my character, even if it's in the middle of an animation. In fact, depending on said animation, the resulting force varies considerably.
Here's an example of how it looks like when "killing" the character (disabling it's animator) while it's "Idle": Wonky Behavior.
So why not disable the Character Controller at the moment of death? After all, since the character is dying, there's no need for the controller any more. Well, I did. But the force it applies seems to linger for a bit (approximately 0.4 seconds in my experience), and making the character "wait" to die is not desirable.
If I move the model away from the reach of the Character Controller, it no longer applies said "force" to the model, and the Ragdoll works as intended. But doing this changes the moving behavior of the character. Here's how the character's death looks like with a disabled Character Controller: Ideal Behavior
Am I doing something wrong? Is there a way to completely stop the force the Character Controller is applying to the object before disabling it? Is there another approach to implement a character's death through Ragdolls?
Any help would be greatly appreciated.
Cheers!
Answer by petersvp · Jul 07, 2017 at 03:09 PM
Debugging the order of code, reading about https://docs.unity3d.com/Manual/ExecutionOrder.html, and then altering / writing your own character controller that handles these in order is the only solution.
Preferably, I always write single character control script that have functions for moving it and statekeeping, and separate control scripts that feed control events either from input or from AI.