Cleanup is going to take awhile, so the site is back up but editing has been disabled.

Creating Ragdoll Models

From HalfLife 2 Knowledge Base

Jump to: navigation, search

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. Here is an example of a simple ragdoll model in milkshape.

Ragdoll.gif

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 "<path to model directory>" 
 $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 "<path to model directory>" 
 $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.

Personal tools