This article's documentation is for anything that uses the Source engine. Click here for more information.

$collisionjoints: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
mNo edit summary
No edit summary
 
(37 intermediate revisions by 18 users not shown)
Line 1: Line 1:
{{stub}}
{{toc-right}}
The [[QC command]] [[$collisionjoints]] is used to setup the ragdoll or [[jointed collision model]].
{{note|[[Jointed collision model]]s use [[$collisionjoints]] instead of [[$collisionmodel]].}}
* See also [[Physics and Ragdolls]].


== Example Syntax==
{{this is a|QC command|name=$collisionjoints}} It is used to define a [[collision mesh]] made up of multiple independent parts, either for a [[ragdoll]] or for [[$sequence|an animated object]]. If your model has no moving parts that need to collide, use <code>[[$collisionmodel]]</code> instead.
[[$collisionjoints]] "bip01_phys.smd" {
[[$mass]] 115.0
[[$inertia]] 2.00
[[$damping]] 0.01
[[$rotdamping]] 0.40
[[$rootbone]] "bip01_pelvis"
[[$jointmerge]] "bip01_pelvis" "bip01_spine"
[[$jointmassbias]] "bip01_l_arm2" 2.00
[[$jointconstrain]] "bip01_l_arm2" x limit 0.00 0.00 0.00
[[$jointconstrain]] "bip01_l_arm2" y limit 0.00 0.00 0.00
[[$jointconstrain]] "bip01_l_arm2" z limit -120.00 4.00 0.20
[[$jointrotdamping]] "bip01_head" 5.00
[[$jointconstrain]] "bip01_head" x limit -20.00 20.00 0.00
[[$jointconstrain]] "bip01_head" y limit -25.00 25.00 0.04
[[$jointconstrain]] "bip01_head" z limit -13.00 30.00 0.04
}


==General Parameters==
A ragdoll can have up to 32 separate parts (i.e. 32 bones can be simulated, 24 on older versions of Source). The limit for an animated model is 99 separate parts.


; [[$mass]] <kilograms>
{{tip|Use <code>vcollide_wireframe 1</code> to view collision meshes in-game.}}
: Manually set the mass, in kilograms, of the model.  
{{warning|Each convex part will produce a [[phys_bone_follower]] entity on [[prop_dynamic]] (but not on [[prop_ragdoll]]), potentially using up large parts of the entity count and networking traffic. Using this for models that are to be repeated many times isn't a good idea!}}
:* This is applicable when the object is a physics prop, rather than simply a static prop. Make certain to set this correctly, otherwise your object will behave unrealistically.
{{bug|$collisionjoints appears to have issues when only 1 joint is defined and used on a [[prop_dynamic]]. The position is broken and the joint does not animate. A workaround for this is to define a <code>bone_followers</code> section under [[$keyvalues]], for example:
<code>
$keyvalues
{
bone_followers
{
"bone" "mycoolbone"
}
}
</code>
}}


; [[$automass]]
== Syntax ==
: Automatically compute the mass of the model.
:* Derived from the density/thickness of the material defined by [[$surfaceprop]] and/or [[Prop Data|prop_data]] and the volume of the [[$collisionmodel]] itself.


; [[$masscenter]] <X Y Z offset?>
[[$collisionjoints]] <collision mesh [[Studiomdl Data|SMD]]/[[DMX|DMX]]>
: Override the center of mass, in local coords.
{
 
    <options>
; [[$inertia]] <scale?>
}
: Inertia scale.
 
; [[$damping]] <scale?>
: Linear damping scale.
 
; [[$rotdamping]] <scale?>
: Rotational damping scale.
 
; [[$drag]] <scale?>
: Scales the air resistance.
 
== Joint Parameters ==
 
; [[$rootbone]] <bone_name?>
: The parent-most bone that actually has collision geometry.
 
; [[$jointskip]] <bone_name?>
: Eliminates a joint in the collision model that you don't want to use. (Rarely used.)
:* (eg: if you were using a render model as a ragdoll, and it has bones you don't want)
 
; [[$jointmerge]] <bone_name1> <bone_name2>
: Merges the vertex assignments for two joints.
 
; [[$jointconstrain]] <bone_name> <axis> <allow_option> <min_angle> <max_angle> <friction>
: Limits of the a bone's movement relative to its parent bone.


; [[$jointinertia]] <scale?>
== Options ==
: Like $inertia, but per-bone.


; [[$jointdamping]] <scale?>
; All <code>[[$collisionmodel]]</code> options, ''except <code>$concave</code>''
: Like $damping, but per-bone.  
: {{confirm|Is $masscenter allowed?}}
; $concaveperjoint
: Permit concave collision geometry for individual bones.
; $rootbone <[[string]]|bone>
: Overrides the collision mesh's root bone.
; $jointskip <[[string]]|bone>
:  Eliminates a joint in the skeleton that you don't want to use in collisions.
;  <code>$jointmerge <[[string]]|bone1> <[[string]]|bone2></code>
:  Merges the vertex assignments for two joints.
; <code>[[$jointconstrain]] <[[string]]|bone> <axis> <allow_option> <min_angle> <max_angle> <friction></code>
: Limits of the a bone's movement relative to its parent bone. See [[$jointconstrain]] for a full description.
; <code>$jointinertia <[[string]]|bone> <[[float]]|scale></code>
: Per-bone <code>[[$inertia]]</code>.
; <code>$jointdamping <[[string]]|bone> <[[float]]|scale></code>
: Per-bone <code>[[$damping]]</code>.
; <code>$jointrotdamping <[[string]]|bone> <[[float]]|scale></code>
: Per-bone <code>[[$rotdamping]]</code>.
; <code>$jointmassbias <[[string]]|bone> <[[float]]|bias></code>
: Mass is automatically distributed by volume, this lets you bias it per-bone.
; <code>$noselfcollisions</code>
: Disables collisions between bones in the same collision model for performance.
: {{warning|Results in arms clipping through torsos and other weirdness if used improperly!}}
; <code>$jointcollide <[[string]]|bone1> <[[string]]|bone2></code>
: If any <code>$jointcollide</code> pairs are specified, only those joints collide with each other.
: {{bug|Does not work in Left 4 Dead or Left 4 Dead 2, instead disabling self collisions entirely.|only=l4d2}}
; <code>$animatedfriction <[[float]]|FrictionTimeIn> <[[float]]|FrictionTimeOut> <[[float]]|FrictionTimeHold> <[[float]]|MinAnimatedFriction> <[[float]]|MaxAnimatedFriction></code>
: Used to animate the amount of friction on joints over time. This can be used to make character death ragdolls tense up.
: {{bug|Only works on C_ClientRagdoll entity, does not work on traditional player death ragdolls or serverside ragdolls.|}}


; [[$jointrotdamping]] <scale?>
== Example ==
: Like $rotdamping, but per-bone.


; [[$jointmassbias]] <bone_name?> <value?>
<source lang=php>
: Mass is automatically distributed by volume, this lets you bias it per-bone.  
$collisionjoints "bip01_phys.smd"
{
$mass 115.0
$inertia 2.00
$damping 0.01
$rotdamping 0.40
$rootbone "bip01_pelvis"
$jointmerge "bip01_pelvis" "bip01_spine"


; [[$noselfcollisions]]
$jointmassbias "bip01_l_arm2" 2.00
: Turns off all collisions between bones in this model, usually for performance.  
$jointconstrain "bip01_l_arm2" x limit 0.00 0.00 0.00
$jointconstrain "bip01_l_arm2" y limit 0.00 0.00 0.00
$jointconstrain "bip01_l_arm2" z limit -120.00 4.00 0.20


; [[$jointcollide]] <bone_name1?> <bone_name2?>
$jointrotdamping "bip01_head" 5.00
: If any $jointcollide pairs are specified, only those joints collide with each other.  
$jointconstrain "bip01_head" x limit -20.00 20.00 0.00
$jointconstrain "bip01_head" y limit -25.00 25.00 0.04
$jointconstrain "bip01_head" z limit -13.00 30.00 0.04
}
</source>


; [[$animatedfriction]] <animation_name?>
== See also ==
: Used to animate the amount of friction on joints over time.


[[Category:QC Commands]]
*[[$weightlist]]
*[[VPhysics]]
*[[Physics and Ragdolls]]
*[[$collisionmodel]]
* [https://www.youtube.com/watch?v=NxmCzkQBXrc YouTube tutorial on $collisionjoints]

Latest revision as of 21:25, 16 July 2025

$collisionjoints is a QC command available in all Source Source games. It is used to define a collision mesh made up of multiple independent parts, either for a ragdoll or for an animated object. If your model has no moving parts that need to collide, use $collisionmodel instead.

A ragdoll can have up to 32 separate parts (i.e. 32 bones can be simulated, 24 on older versions of Source). The limit for an animated model is 99 separate parts.

Tip.pngTip:Use vcollide_wireframe 1 to view collision meshes in-game.
Warning.pngWarning:Each convex part will produce a phys_bone_follower entity on prop_dynamic (but not on prop_ragdoll), potentially using up large parts of the entity count and networking traffic. Using this for models that are to be repeated many times isn't a good idea!
Icon-Bug.pngBug:$collisionjoints appears to have issues when only 1 joint is defined and used on a prop_dynamic. The position is broken and the joint does not animate. A workaround for this is to define a bone_followers section under $keyvalues, for example:

$keyvalues { bone_followers { "bone" "mycoolbone" } }

  [todo tested in ?]

Syntax

$collisionjoints <collision mesh SMD/DMX>
{
    <options>
}

Options

All $collisionmodel options, except $concave
Confirm:Is $masscenter allowed?
$concaveperjoint
Permit concave collision geometry for individual bones.
$rootbone <string|bone>
Overrides the collision mesh's root bone.
$jointskip <string|bone>
Eliminates a joint in the skeleton that you don't want to use in collisions.
$jointmerge <string|bone1> <string|bone2>
Merges the vertex assignments for two joints.
$jointconstrain <string|bone> <axis> <allow_option> <min_angle> <max_angle> <friction>
Limits of the a bone's movement relative to its parent bone. See $jointconstrain for a full description.
$jointinertia <string|bone> <float|scale>
Per-bone $inertia.
$jointdamping <string|bone> <float|scale>
Per-bone $damping.
$jointrotdamping <string|bone> <float|scale>
Per-bone $rotdamping.
$jointmassbias <string|bone> <float|bias>
Mass is automatically distributed by volume, this lets you bias it per-bone.
$noselfcollisions
Disables collisions between bones in the same collision model for performance.
Warning.pngWarning:Results in arms clipping through torsos and other weirdness if used improperly!
$jointcollide <string|bone1> <string|bone2>
If any $jointcollide pairs are specified, only those joints collide with each other.
Icon-Bug.pngBug:Does not work in Left 4 Dead or Left 4 Dead 2, instead disabling self collisions entirely.  [todo tested in ?]
$animatedfriction <float|FrictionTimeIn> <float|FrictionTimeOut> <float|FrictionTimeHold> <float|MinAnimatedFriction> <float|MaxAnimatedFriction>
Used to animate the amount of friction on joints over time. This can be used to make character death ragdolls tense up.
Icon-Bug.pngBug:Only works on C_ClientRagdoll entity, does not work on traditional player death ragdolls or serverside ragdolls.  [todo tested in ?]

Example

$collisionjoints "bip01_phys.smd"
{
	$mass			115.0
	$inertia		2.00
	$damping		0.01
	$rotdamping		0.40
	$rootbone		"bip01_pelvis"
	$jointmerge		"bip01_pelvis"	"bip01_spine"

	$jointmassbias		"bip01_l_arm2"	2.00
	$jointconstrain		"bip01_l_arm2"	x limit	0.00 0.00 0.00
	$jointconstrain		"bip01_l_arm2"	y limit	0.00 0.00 0.00
	$jointconstrain		"bip01_l_arm2"	z limit	-120.00 4.00 0.20

	$jointrotdamping	"bip01_head"	5.00
	$jointconstrain		"bip01_head"	x limit	-20.00 20.00 0.00
	$jointconstrain		"bip01_head"	y limit	-25.00 25.00 0.04
	$jointconstrain		"bip01_head"	z limit	-13.00 30.00 0.04
}

See also