Flail Ragdoll

I’m trying to make a flail model into a ragdoll. I have the bones and everything set up, I just need to compile it.

Can anyone give me some help with what my .qc should contain for this particular model? I’ve compiled static models before but never ragdolls.
I’ve also searched a few threads but i still can’t seem to get it to work properly, I don’t really know what I’m doing to be honest.


Assuming you set up collision boxes for the sections and linked the bones correctly, there’s not much you need to put in the .QC at the moment. Just $collisionmodel and $mass and whatever else you put in there to compile. Doing joint constraints is very easy, but it can be tedious depending on the amount of bones/collision hulls you set up. You’ll have to open the model up in the model viewer once it’s compiled and go to the ‘physics’ tab and set up joint constraints. There should be a drop-down box here that has each collision box that you set up. I recommend you tick the checkbox that says ‘Highlight’.

What you need to do here is go through each collision section and set how far each section will rotate/turn on the X, Y, and Z axes. You drag the ‘Test’ slider to the far right or far left (left will drag it to the minimum, right will drag it to the maximum movement). I should mention the test slider can be sticky sometimes and you usually have to touch it if you move onto a new bone/collision hull for it to activate, even if it is stuck on the far left when you go to that bone. With the test slider to the right or left, you then drag the max/min sliders to how far you want it to move on the specific axis that you have selected on the X/Y/Z checkboxes. This is a bit of a convoluted description, so I highly recommend you load up a pre-compiled ragdoll in the model viewer and fiddle around with his joint constraints in the physics tab so you can get the idea.

In this image, for example, you can see I have the head collision hull selected and I’m setting the maximum movements for how far Max Payne can move his head left or right on the X axis. (Ideally since he’s turning his head left or right, those numbers should be equal and opposite like -53 and +53 but I was too lazy. Something like the Z axis for Max’s head would be different, where I would make Max’s minimum distance of how far he can move his head down larger than his maximum distance of how far he can move his head to look up because that is generally how necks work.)


Once you’ve finished the max and min distances for one axis on one bone/collision hull, do the other axes until you can move onto the next bone and so on. When you’re all done doing the joint constraints, press the ‘Generate QC’ button and it will copy what you’ve done to your clipboard. Paste it in a text editor and copy all of the $jointconstraint lines, mass, etc. and paste it into your .QC inside the $collisionmodel bit, then recompile. Here’s an example of the $jointconstraints for Max Payne:

$collisionjoints "phymodeltieless.smd" {

	$mass 70.0
	$inertia 10.00
	$damping 0.01
	$rotdamping 1.50
	$rootbone "valvebiped.bip01_pelvis"

	$jointconstrain "valvebiped.bip01_l_thigh" x limit -30.00 12.00 0.00
	$jointconstrain "valvebiped.bip01_l_thigh" y limit -73.00 50.00 0.00
	$jointconstrain "valvebiped.bip01_l_thigh" z limit -73.00 53.00 0.00

	$jointconstrain "valvebiped.bip01_l_calf" x limit -26.00 15.00 0.00
	$jointconstrain "valvebiped.bip01_l_calf" y limit 0.00 0.00 0.00
	$jointconstrain "valvebiped.bip01_l_calf" z limit -8.00 138.00 0.00

	$jointconstrain "valvebiped.bip01_r_thigh" x limit -12.00 30.00 0.00
	$jointconstrain "valvebiped.bip01_r_thigh" y limit -50.00 73.00 0.00
	$jointconstrain "valvebiped.bip01_r_thigh" z limit -73.00 53.00 0.00

	$jointconstrain "valvebiped.bip01_r_calf" x limit -13.00 30.00 0.00
	$jointconstrain "valvebiped.bip01_r_calf" y limit 0.00 0.00 0.00
	$jointconstrain "valvebiped.bip01_r_calf" z limit -12.00 122.00 0.00

	$jointconstrain "valvebiped.bip01_r_foot" x limit -17.00 23.00 0.00
	$jointconstrain "valvebiped.bip01_r_foot" y limit -25.00 35.00 0.00
	$jointconstrain "valvebiped.bip01_r_foot" z limit -32.00 48.00 0.00

	$jointconstrain "valvebiped.bip01_spine2" x limit -48.00 48.00 0.00
	$jointconstrain "valvebiped.bip01_spine2" y limit -25.00 25.00 0.00
	$jointconstrain "valvebiped.bip01_spine2" z limit -25.00 50.00 0.00

	$jointmassbias "tie3" 0.10
	$jointconstrain "tie3" x limit -37.00 41.00 0.00
	$jointconstrain "tie3" y limit -70.00 55.00 0.00
	$jointconstrain "tie3" z limit -53.00 55.00 0.00

	$jointconstrain "valvebiped.bip01_l_clavicle" x limit 0.00 0.00 0.00
	$jointconstrain "valvebiped.bip01_l_clavicle" y limit -30.00 26.00 0.00
	$jointconstrain "valvebiped.bip01_l_clavicle" z limit -12.00 19.00 0.00

	$jointconstrain "valvebiped.bip01_l_upperarm" x limit -39.00 39.00 0.00
	$jointconstrain "valvebiped.bip01_l_upperarm" y limit -111.00 84.00 0.00
	$jointconstrain "valvebiped.bip01_l_upperarm" z limit -111.00 48.00 0.00

	$jointconstrain "valvebiped.bip01_l_forearm" x limit -55.00 50.00 0.00
	$jointconstrain "valvebiped.bip01_l_forearm" y limit -10.00 26.00 0.00
	$jointconstrain "valvebiped.bip01_l_forearm" z limit -149.00 4.00 0.00

	$jointconstrain "valvebiped.bip01_l_hand" x limit -68.00 68.00 0.00
	$jointconstrain "valvebiped.bip01_l_hand" y limit -68.00 75.00 0.00
	$jointconstrain "valvebiped.bip01_l_hand" z limit -66.00 64.00 0.00

	$jointconstrain "valvebiped.bip01_r_clavicle" x limit 0.00 0.00 0.00
	$jointconstrain "valvebiped.bip01_r_clavicle" y limit -26.00 30.00 0.00
	$jointconstrain "valvebiped.bip01_r_clavicle" z limit -12.00 19.00 0.00

	$jointconstrain "valvebiped.bip01_r_upperarm" x limit -48.00 46.00 0.00
	$jointconstrain "valvebiped.bip01_r_upperarm" y limit -79.00 111.00 0.00
	$jointconstrain "valvebiped.bip01_r_upperarm" z limit -117.00 55.00 0.00

	$jointconstrain "valvebiped.bip01_r_forearm" x limit -32.00 50.00 0.00
	$jointconstrain "valvebiped.bip01_r_forearm" y limit -26.00 12.00 0.00
	$jointconstrain "valvebiped.bip01_r_forearm" z limit -149.00 4.00 0.00

	$jointconstrain "valvebiped.bip01_r_hand" x limit -68.00 68.00 0.00
	$jointconstrain "valvebiped.bip01_r_hand" y limit -57.00 50.00 0.00
	$jointconstrain "valvebiped.bip01_r_hand" z limit -66.00 94.00 0.00

	$jointconstrain "valvebiped.bip01_neck1" x limit -19.00 19.00 0.00
	$jointconstrain "valvebiped.bip01_neck1" y limit -19.00 19.00 0.00
	$jointconstrain "valvebiped.bip01_neck1" z limit -35.00 26.00 0.00

	$jointconstrain "valvebiped.bip01_head1" x limit -53.00 55.00 0.00
	$jointconstrain "valvebiped.bip01_head1" y limit -32.00 32.00 0.00
	$jointconstrain "valvebiped.bip01_head1" z limit -29.00 67.00 0.00

	$jointmassbias "tie4" 0.10
	$jointconstrain "tie4" x limit -37.00 41.00 0.00
	$jointconstrain "tie4" y limit -70.00 55.00 0.00
	$jointconstrain "tie4" z limit -53.00 55.00 0.00

	$jointconstrain "valvebiped.bip01_l_foot" x limit -28.00 30.00 0.00
	$jointconstrain "valvebiped.bip01_l_foot" y limit -19.00 19.00 0.00
	$jointconstrain "valvebiped.bip01_l_foot" z limit -30.00 46.00 0.00

	$animatedfriction 1.000 400.000 0.500 0.300 0.000

As you can see, it has all the axis limits and their values for the maximum and minimum. I believe the last 0.00 is for friction if you choose to set any, or fiddle with mass biases/inertia/damping options. For your flail, I’d probably set a mass bias for the middle chain bits so they appear lighter than the rest of the flail. I put in a tie for my Max Payne and I decided I didn’t want his tie to weigh his whole model down, as it would use the same mass of 70 kg if I didn’t set mass bias, so I put in a $jointmassbias for his tie bones. That’s entirely up to you, but it might give your flail a bit of flair.

[editline]13th September 2013[/editline]

If you don’t know how to set up collision models and bones for ragdolls, you need to have some bones. You need a root/parent bone (one for the handle would probably be fine) and children bone(s). I’m not sure what you’re using for 3D software, but in 3DS Max there is a bone linking tool where you link a child bone to a parent bone, and another child bone to the first child bone, etc. This is an alright picture of showing how to link bones in 3DS Max. There’s the little chain link icon in the top bar. Say you have 3 bones of a hand, a forearm, and the upper arm. You want to link the hand bone to the forearm bone, and then link the forearm bone to the upper arm bone (which, in this case, would be the parent bone if you’re just compiling a severed arm). You click and drag to link a bone in 3DS Max. A fairly easy way to tell what is a parent bone is if you were to move the parent bone and the children bones would rotate with it. In the severed arm example, rotating the upper arm bone would also rotate the fore arm and hand bones because they are the children. If you rotate the fore arm bone, the hand bone would move with it but not the upper arm. It’s just like in real life - your whole arm doesn’t move if you move your hand. Wow! Amazing! Great job!

For a collision model, you set up boxes that would collide with the world in Source for each section/bone that you want to collide with things or have the player pick it up with the physgun in GMod. The severed arm, for example, would have 3 boxes. You don’t need to make the boxes complicated, generally a cube will do for most circumstances - but you can go further and do spheres and such. The easiest way I’ve found to do the collision models for ragdolls is to have each box as a separate shape and not have them connected in any way. Each box should have a separate smoothing group. In 3DS Max, that’s the ‘Smooth’ modifier. Each box also needs a ‘Skin’ modifier (again for 3DS Max, I am not sure what the equivalent is for Blender or Maya). The skin modifier only needs ONE bone selected in it, and all vertices of that collision box must be weighted to ONE bone. The collision box for the hand would have the hand bone in its skin modifier, the forearm box has the forearm bone, upper arm box has the upper arm bone. Again, not as complicated as it seems. You delete the arm mesh and only compile the bones and collision boxes as a reference smd and include that as your $collisionmodel in the QC.

Thanks! I think i understand most of what i need to do, but could you post a picture of an example QC for the first compile you do?

Also is it just the collision model that needs the bones exported with it?

You need the mesh with the bones as one smd, the ragdoll.smd which is only the bones as another, and the collision smd which is bones + collision model. I forgot to mention the ragdoll.smd part earlier. Doesn’t have to be called ragdoll.smd, obviously. I believe static props need a $sequence in their QC as well so I’m sure you can just take one of your old QCs and slap that in there.

I don’t have a .QC from any ragdolled props I’ve done, but here’s one from an older character which has a lot less stuff in it than my Max Payne QCs and is a much cleaner and easier to read. This should do fine as a first compile before you add in the joint constraints. (Sorry I misread your post the first time and had to edit this one quick)

$cd "C:\Users\Home\Documents\3dsmax\PROJECTS\zombs\z28"
$modelname "zombies/z28.mdl"
$model "studio" "zomb.smd" {
$cdmaterials "models\zombies"

$surfaceprop "flesh"
$sequence ragdoll "ragdoll" ACT_DIERAGDOLL 1 fps 30.00 //Unless you're doing an NPC or something, ACT_DIERAGDOLL probably isn't necessary here https://developer.valvesoftware.com/wiki/$sequence
$collisionjoints "phymodel.smd" {

	$mass 90.0
	$inertia 10.00
	$damping 0.01
	$rotdamping 1.50

[editline]13th September 2013[/editline]

That’s weird, I always remember it as $collisionmodel but the actual line is $collisionjoints.