[fusion_builder_container hundred_percent=”no” equal_height_columns=”no” menu_anchor=”” hide_on_mobile=”small-visibility,medium-visibility,large-visibility” class=”” id=”” background_color=”” background_image=”” background_position=”center center” background_repeat=”no-repeat” fade=”no” background_parallax=”none” parallax_speed=”0.3″ video_mp4=”” video_webm=”” video_ogv=”” video_url=”” video_aspect_ratio=”16:9″ video_loop=”yes” video_mute=”yes” overlay_color=”” video_preview_image=”” border_size=”” border_color=”” border_style=”solid” padding_top=”” padding_bottom=”” padding_left=”” padding_right=””][fusion_builder_row][fusion_builder_column type=”1_1″ layout=”1_1″ background_position=”left top” background_color=”” border_size=”” border_color=”” border_style=”solid” border_position=”all” spacing=”yes” background_image=”” background_repeat=”no-repeat” padding_top=”” padding_right=”” padding_bottom=”” padding_left=”” margin_top=”0px” margin_bottom=”0px” class=”” id=”” animation_type=”” animation_speed=”0.3″ animation_direction=”left” hide_on_mobile=”small-visibility,medium-visibility,large-visibility” center_content=”no” last=”no” min_height=”” hover_type=”none” link=””][fusion_text]
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
Basic Requirements
- Understanding of the Unity Game Engine
- Knowledge of the Unity Animation, Rigidbody & Collider Component
Site : https://unity3d.com/get-unity/download/archive
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.”

Here
- 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.
-
Character Head value -
Character Left Upper Arm value -
Character Left ForeArm value -
Character Right Forearm -
Character Right Calf -
Character Left Calf
- 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.
using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
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
void Update()
{
if (isDead)
return;
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)
{
playerAnim.SetBool("isWalking", true);
}
else
{
playerAnim.SetBool("isWalking", false);
}
if (Input.GetKeyDown(KeyCode.Space))
{
isDead = true;
playerModel.SetActive(false);
playerRagdoll.transform.position = playerModel.transform.position;
playerRagdoll.SetActive(true);
}
}
}
- 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.
-
Idle to walk transition -
walk to idle transition
Camera Setup
- 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.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CameraFollowController : MonoBehaviour
{
public Transform followTarget;
public float followSpeed=5;
private Vector3 offset;
// Start is called before the first frame update
void Start()
{
offset = followTarget.position - transform.position;
}
private void FixedUpdate()
{
if (followTarget)
{
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.

Final Output

Summary
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.
[/fusion_text][/fusion_builder_column][/fusion_builder_row][/fusion_builder_container]