Ads keep us online. Without them, we wouldn't exist. We don't have paywalls or sell mods - we never will. But every month we have large bills and running ads is our only way to cover them. Please consider unblocking us. Thank you from GameBanana <3

Creating Ragdoll Models - A Tutorial for Source Engine

The following tutorial shows how to create a ragdoll model. These models are for more than just characters. The famous mattress model is a ragdoll model. If you want parts of a model to swing or move separately from the rest then you should use a ragdoll model. To use a ragdoll model you use prop_ragdoll instead of prop_static or prop_dynamic. To create a ragdoll model you must create one with separate bones for each part of the model which will move. Create a reference smd file from milkshape or your favorite editing tool. If you were going to just compile this model as a static prop you would use the following .qc file
 $modelname "mymodels/myragdoll.mdl"
 $scale 1.0 
 $cd "" 
 $body "Body" myragdoll.smd 
 $cdmaterials "models\mymodelmaterials"
 $staticprop 
  // 1 sequence 
 $sequence idle "myragdoll" fps 5 ACT_IDLE 1
  $surfaceprop "wood"
  $keyvalues { "prop_data" {"base" "wooden.large" } 
  $cdmaterials "models\mymodels"
  $collisionmodel "myragdoll.smd" { 
 // Mass in kilograms 
   $concave
   $mass 500.0
 }
 
To change this to a ragdoll model you change the $collisionmodel to $collisionjoints and specify how the joints can rotate with respect to the root joint. An example .qc is as follows
$modelname "mymodels/myragdoll.mdl"
 $scale 1.0 
 $cd "" 
 $body "Body" myragdoll.smd 
 $cdmaterials "models\mymodelmaterials"
 //$staticprop 
 // 1 sequence 
 $sequence idle "myragdoll" fps 5 ACT_IDLE 1
 $surfaceprop "wood"
 $keyvalues { "prop_data" {"base" "wooden.large" } 
 $cdmaterials "models\mymodels"
 $collisionjoints "myragdoll_ragdoll.smd" { 
 // Mass in kilograms 
   $rootbone "joint1" 
   $concave
   $mass 80.0
   $inertia 5.00
   $damping 0.01
   $rotdamping 1.50
   $jointconstrain joint1 x limit 0.000000 0.000000 0.000000
   $jointconstrain joint1 y limit 0.000000 0.000000 0.000000
   $jointconstrain joint1 z limit 0.000000 0.000000 0.000000
   $jointconstrain joint2 x limit -90.000000 90.000000 1.000000
   $jointconstrain joint2 y limit -90.000000 90.000000 1.000000
   $jointconstrain joint2 z limit -45.000000 45.000000 1.000000
   $jointconstrain joint3 x limit -90.000000 90.000000 1.000000
   $jointconstrain joint3 y limit -90.000000 90.000000 1.000000
   $jointconstrain joint3 z limit -45.000000 45.000000 1.000000
}
Each of the jointconstrain commands control the joint rotation in a specific axis. For example the above .qc allows joint2 and joint3 to rotate +/- 90 degrees in the x and y and +/- 45 degrees in the z (up/down) axis. In the above example I used boxes for each of the joints, so I don't need to create a separate ragdoll collision model. If your model is more complicated, then for the collision model you should create a new .smd with one box assigned to each joint. The box will be used for collisions for that joint and the size will determine the weight of the joint. Tutorial by WikiPedia, brought to CSB by [Xero].