![]() | Your First Animated Ragdoll |
In this section, you will learn the basics of setting up animated ragdolls using the example assets included in Ragdoll Workshop.
This topic contains the following sections:
Ragdoll Workshop also includes facilities for driving a physical ragdoll with animation data. It does so by binding a Ragdoll object to a RagdollAnimator object (e.g., TetrapodRagdoll / TetrapodRagdollAnimator or HumanoidRagdoll / HumanoidRagdollAnimator).
Follow the steps in the Your First Ragdoll tutorial to create a fully characterized HumanoidRagdoll (either Generic or Humanoid Avatar is fine) and a ground plane.
Press the green Prepare for Physical Animation button in the Inspector for the HumanoidRagdoll component.
When the prompt appears to ask if you would like to add a Character Controller, select No. You should now have the Animation Driver object with the HumanoidRagdollAnimator component selected.
![]() |
---|
The Prepare for Physical Animation Button rearranges your hierarchy so that two GameObject hierarchies, Ragdoll (with the HumanoidRagdoll component) and Animation Driver (with a HumanoidRagdollAnimator component) are both children of a new GameObject such as e.g., Dude - Humanoid Animated Ragdoll. |
Create a new Animator Controller (Assets -> Create -> Animator Controller). Double click it to open the Animator Window.
In the Parameters Tab, add two bool parameters named Is Ragdoll and Is Supine.
Return to the Layers Tab and drag the appropriate idle_tired AnimationClip for your character from the Project Window into the animation graph. Its node should be orange to indicate it is the default state. Repeat this process for getup_prone_tired and getup_supine_tired.
![]() |
---|
These clips are found in either Plugins/Candlelight/Asset Store Products/Ragdoll Workshop/Examples/Animations/Generic or Plugins/Candlelight/Asset Store Products/Ragdoll Workshop/Examples/Animations/Humanoid , depending which avatar type you are using. |
Create transitions from each getup AnimationState to the idle AnimationState. These transitions need no conditions.
Create an empty AnimationState and name it Ragdoll.
From the Inspector for the Ragdoll state, click the Add Behaviour button and select RagdollState.
Create a transition from the Any State node to the Ragdoll node and add the condition that it should transition when the Is Ragdoll parameter is true.
Create a transition from the Ragdoll state to the getup_prone_tired state. Add the condition that it should transition when the Is Ragdoll parameter is false and the Is Supine parameter is false.
Create a transition from the Ragdoll state to the getup_supine_tired state. Add the condition that it should transition when the Is Ragdoll parameter is false and the Is Supine parameter is true. Your controller should look something like that shown in the image below.
Assign your new Animator Controller to the Animator component on the Animation Driver object.
Select the Is Supine parameter for the Supine Parameter field in the Inspector for the HumanoidRagdollAnimator component.
Add the RagdollToggleTest component to the Dude - Humanoid Animated Ragdoll (or Dude - Generic Animated Ragdoll, if applicable) GameObject in your scene.
Ensure that the Is Ragdoll parameter is selected for the Ragdoll Parameter field.
Press play!
While the character is playing its idle animation, press the F key to make it go ragdoll. When it has settled on the ground, press the F key again to make it transition to its appropriate getting up animation.
A RagdollAnimator is a non-rendered hierarchy of only Transform components, which acts as a source of physical force data for a Ragdoll . Any parts defined on the Ragdoll that are not also defined on the RagdollAnimator will be controlled by physics at all times. Any parts defined on the RagdollAnimator that are not also defined on the Ragdoll will have no effect. Arbitrary chains are matched by name, and they, along with spines and necks, should contain the same number of bodies in both the Ragdoll and RagdollAnimator. Parts for TetrapodRagdollAnimator can be located automatically, which uses the same logic outlined for TetrapodRagdoll.
When driving a ragdoll with animation data, the object with the RagdollAnimator component should have an Animator, but the Ragdoll object should not.
The animator controller being used by a RagdollAnimator can define any number of ragdoll states. Such states contain no animation data, but have a RagdollState behaviour attached. A controller may have any number of RagdollStates, and they can exist on layers that have only specific transforms or body parts masked. The controller logic thus determines how and when the character enters ragdoll, as well as which body parts enter ragdoll. The strength of any particular part is inversely proportional to the weight of all layers with ragdoll states affecting it.
In order to allow tetrapod characters to get back up from full-body ragdoll, you must define at least one getting up state for supine (face up) orientation and one for prone (face down) orientation. Your controller should contain a bool parameter for this orientation, which determines the state to enter when exiting full-body ragdoll, and which you should specify on the TetrapodRagdollAnimator, as it updates the parameter's value. You also need to specify the ground layers on the RagdollAnimator component. When the character gets back up from full-body ragdoll, the object with the Animator component is repositioned by performing a raycast against these layers. All colliders on the Ragdoll will be automatically ignored, regardless of layer.
If your character is moved using a Character Controller or Rigidbody / Collider at run-time, then the Ragdoll / RagdollAnimator will warn you if there are potentially layer conflicts. You should put all of the parts in the Ragdoll definition on a layer that does not collide with whatever layer the RagdollAnimator's Character Controller or Collider is on.
If you have control scripts that move the RagdollAnimator, such as the CharacterMotor script, these scripts should usually perform movements in the FixedUpdate() loop, rather than the Update() loop, as it will happen more frequently in most games. Otherwise the character's parts may have no velocity on many frames. You should disable your movement scripts when the character enters full-body ragdoll and re-enable it when the character exits. You can do this by using the OnEnterFullHierarchyRagdoll / OnExitFullHierarchyRagdoll events on the RagdollAnimator.