What is Ragdoll in Unity?
Unity has a simple wizard that lets you quickly create your own Ragdoll. You have to drag the different limbs on the respective properties in the wizard. Then select create, and Unity will automatically generate all Colliders, Rigidbodies, and Joints that make up the Ragdoll for you. This allows you to do a combination of physics and “animations” so the object behaves as a normal body would. (at least almost) :D
- Understanding of the Unity Game Engine
- Knowledge of the Unity Animation, Rigidbody & Collider Component
How to create Ragdoll in Unity
Create a new Unity Project
- Here I am using the latest version of Unity 2020.1
- Save the project with a name and 3D Templates.
Download 3D character from Asset Store
- There are many Animated 3d models available on the Asset Store.
- Download this excellent 3d character – https://assetstore.unity.com/packages/3d/characters/humanoids/character-pack-free-sample-79870
Import downloaded character to your project
- Open the Package Manager and select this downloaded character.
- Import the character model to the current project.
- You will find the model in the Project Window.
- Drag the unity model to Hierarchy Window and Drop there.
- You can change the character’s position & rotation according to camera view in Inspector Window> Transform component.
- Rotate Character model in Y-axis 0 to 180.
- The rigged animated model has by default an Animator controller in it. It controls animation transitions.
- Here our model is not in T shape but ragdoll is going to work because Rig is perfect.
Configure the Character Model
- Model is not in T shape so you have to configure the character model
- You will see how you can configure any character and what rigged parts in any humanoid character then open model settings.
- In the Project Window, Go to the Character Model file and click on it.
- In the Inspector Window, Click on Rig menu of Model Setting.
- Select the Avatar Definition field and select the “Create for This Model” option.
- Click on Configure Button.
- you can see the mapping of the model.
- Here it shows a warning that our model is not in T shape.
- In the Inspector Window, you will get the “Pose” button at the bottom side on the screen.
- Select the “Enforce T Shape” Option.
- Now, this model is Perfect for Ragdoll System.
Add Ragdoll System
- In the Hierarchy window, Right-click on 3D character and go to the 3D object > Ragdoll.
- Here, one Popup box will appear.
- Here you have to assign the different body parts.
- Pelvis also may be named Hip.
- Right or Left Arm may also be named Upper Arm.
- Right or Left Elbow may also be named Lower Arm.
- So if naming is for you, then detect this position of joints, and you will find the right one.
- Add Model’s Rigged part in Ragdoll System.
- Once you assign all parts in fields, click on “Create Button.”
- You can see that joints and colliders are applied to all rigged parts.
- You can also use Physics Debugger to check the perfect size and view of each part.
Add Physics Debugger Window
- Go to Window > Analysis > Physics Debugger
- If the ragdoll is not correct when you press create. You need to adjust the collider values in each defect collider.
- Change the property of different body parts as below.
- Deactivate the Capsule collider component from the Character model.
Final View of Ragdoll Implementation in Unity
- Right, Click on Object, go to prefab and select unpack option.
- Rename this object from “MobileMaleFreeSimpleMovement1” to “MobileMaleFreeSimpleMovement1_ragdoll“.
- Create a prefab of this updated object.C
Ragdoll Testing Scene
- Download and import 3D asset from Asset Store
- Open “Demo_Scene_1” scene from new Asset. (GO TO – Asset> Toon Gas Station> Scenes)
- In the Hierarchy window, Create an empty game object and rename to “Player“.
- Now attach simple character and ragdoll character as a child objects of Player.
- Deactivate the MobileMaleFreeSimpleMovement1_ragdoll object.
Script to manage the ragdoll in Unity
- Ragdoll is useful for e.g. death animations, so when the character dies the ragdoll should be active.
- Here we create a script that activates ragdoll character objects and deactivates current simple character.
- Create a new folder with the name “Scripts“.
- Create a new c# script with the name “PlayerMovementController” in the Scripts folder.
public class PlayerMovementController : MonoBehaviour
public bool isDead;
public Transform player;
public GameObject playerModel;
public Animator playerAnim;
public float moveSpeed=1;
public GameObject playerRagdoll;
private void Start()
// Update is called once per frame
Vector3 moveDir = new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical"));
player.position += Time.deltaTime * moveSpeed * moveDir;
player.rotation = Quaternion.LookRotation(moveDir);
if (moveDir.x != 0 || moveDir.z != 0)
isDead = true;
playerRagdoll.transform.position = playerModel.transform.position;
- Attach this script to the Player Object.
- assign values in properties
- Now you need to assign an Animator controller in the “MobileMaleFreeSimpleMovement1” object.
- In Project Window, Right-click > create > Animator Controller and Create a new Animator Controller.
- Rename this animator Controller as Player Animator.
- Click on the “MobileMaleFreeSimpleMovement1” object and assign Player Animator to the controller field.
- Open Animator Window
- Click on MobileMaleFreeSimpleMovement1 object.
- Now you have to add two animation clips in animator
- Idle animation
- Walk animation
- Create a bool parameter and rename to “isWalking”.
- Add Animation Transition arrow between animation clips.
- Set a camera behind the player so the camera will see player movement.
- Create a new script with the name “CameraFollowController” that helps the camera to follow the character.
public class CameraFollowController : MonoBehaviour
public Transform followTarget;
public float followSpeed=5;
private Vector3 offset;
// Start is called before the first frame update
offset = followTarget.position - transform.position;
private void FixedUpdate()
transform.position = followTarget.position - offset;
- Assign CameraFollowController script to the Main Camera object.
- Final changes in objects as below
- Change the light setting in the Inspector Window.
In this article, you learned about the Ragdoll system in Unity and how you convert simple character in ragdoll mode. Ragdoll is beneficial in death animation, so I hope you will try this functionality in your own game and create more realistic death animation using this ragdoll.