Unity3D C# ragdoll

Hello, I was so tired of my unity game until I managed to create a ragdoll out of my robot and now I’m going to try create a health script for this Robot and if health is less or equal to zero, he becomes a robot, I was just wondering if anyone knows how to reference “ragdolls” in scripts, like the “Ragdoll” part is turned off while health > 0 and when it reaches 0, he becomes a ragdoll.

Im not asking you to write a script for me, Im just wondering how I’m going to do this

There are two Game Objects with you - one is regular robot and other is ragdoll.

Then check out the below psuedo-code for the same:

if(health > 0) {
   Play with the robot game object here
} else if(health <= 0){
   Instantiate the ragdoll at the place of the robot game object
   Destroy the robot game object
}

Attach this script to your robot game object.

Unity script reference for Instantiate and Destroy

Also check out this article on How to Make an Object Shatter Into Smaller Fragments in Unity. Instead of shattering game object into pieces you replace it with your ragdoll.