# Death Ragdoll

## Overview

The Death Ragdoll State will replace the character by a ragdoll when it dies.

It uses the same State [**ID** ](https://malbersanimations.gitbook.io/animal-controller/scriptable-architecture/scriptables/scriptable-ids#states-ids) **(10**) as the Death State.

<figure><img src="https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2FLkvOP39a2utWHwqe6W47%2FUnity_iOKDOdr7xH.gif?alt=media&#x26;token=08b52f35-6f14-49d6-b7b5-3ce031b8c286" alt=""><figcaption></figcaption></figure>

## How it works

When the Death state is activated, whether when the Health stat is zero or by simply forcing the state; a ragdoll prefab previously created will be instantiated and a force will be applied in the direction of the animations and the stored last Hit from the MDamageable component. The Animal Controller and all its internal components and features will be disabled.&#x20;

When the Ragdoll prefab is instantiated, it will remap or re-skin all the bones of all the skinned meshes inside the animal controller to the ragdoll bones.&#x20;

This is how it looks when the mesh :

{% embed url="<https://streamable.com/gstxt7>" %}

The Ragdoll Prefab is a copy of the character with all the basic ragdoll requirements (Character Joint components, colliders, and Rigidbodies). &#x20;

<figure><img src="https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2FyIBcDIYMrwKzO42eDtCp%2FUnity_GD3shmFqpL.gif?alt=media&#x26;token=3681a040-e78a-4161-9ce2-eac414a3dbb3" alt=""><figcaption><p>Simple Ragdoll Prefab</p></figcaption></figure>

## Creating the State

To create a new Ragdoll State. use the Plus \[+] button on the States list:

<figure><img src="https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2F6o5NlkZ5jxbB7vSQSAuF%2Fimage.png?alt=media&#x26;token=8ed57ed2-627d-4379-882d-c1fcae1e910a" alt=""><figcaption></figcaption></figure>

Or duplicate any of the already created Wall Run States Assets of any character you own and drag it to the States List.

## Priority

The state should have the highest since the character can be killed at any time. &#x20;

<figure><img src="https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2FQAq2qXgXKA3TtDYTbZvN%2Fimage.png?alt=media&#x26;token=c676d708-bd46-4874-94ae-de1f89e62c43" alt=""><figcaption></figcaption></figure>

## Requirements

It only needs a Ragdoll prefab that matches your character.

## Activation

To activate the state you can use the State methods like MAnimal.State\_Activate(10).

&#x20;Usually, the Death state is activated when the Health stat is empty. This connection is set automatically.

<figure><img src="https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2FUuWuUMjKd4XVjTWNwezz%2Fimage.png?alt=media&#x26;token=5fd3ef5f-ea99-4dfc-9364-41d56fe84242" alt=""><figcaption></figcaption></figure>

### Using a Zone

A [**Zone** ](https://malbersanimations.gitbook.io/animal-controller/secondary-components/zones)can activate any state.

<figure><img src="https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2FaU3HONGHpDxg4d6sCVR3%2Fimage.png?alt=media&#x26;token=b3ab2137-11a2-470e-8f07-0f74ac6a45e9" alt=""><figcaption></figcaption></figure>

### Using a Reaction

Animal Reactions can be used to activate the state. Check [**Reactions**](https://malbersanimations.gitbook.io/animal-controller/main-components/reactions)

## Exit Conditions

Ragdoll State does not have any exit conditions. It is a permanent state.

## Animator

Since a ragdoll prefab will replace the Animal Controller, no animation is required.

## Ragdoll Death Parameters

<figure><img src="https://963537199-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Lzhr1XSMzMqNXjRnNlb%2Fuploads%2Fwyqed3VmIPmn6uiMEnJC%2Fimage.png?alt=media&#x26;token=d37ec6bf-35e7-4ce6-a579-98efc0f7ea38" alt=""><figcaption></figcaption></figure>

### Ragdoll Prefab

Reference for the clean ragdoll replacement prefab

### Drag

Set an angular drag to all the ragdoll rigid bodies&#x20;

### Angular Drag

Set an angular drag to all the ragdoll rigid bodies&#x20;

### Enable Preprocessing

enable pre-processing in all the Character joint components

### Collision

What type of collision all the ragdoll rigid bodies will have
