$collisiontext: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
(This one is also a float)
(Updated the page to be much more explicit and clear; adding info on pretty much every option and anywhere that needed more details. I also tested/read the code for all settings to confirm them.)
Line 1: Line 1:
'''[[$collisiontext]]''' defines a breakable model's [[custom gibs]]. (Generic gibs are defined by [[Prop Data#Gibs|$keyvalues > prop_data > breakable_model]]).
'''[[$collisiontext]]''' defines a breakable model's [[custom gibs]]. (Generic gibs are defined by [[Prop Data#Gibs|$keyvalues > prop_data > breakable_model]]).


{{tip|Use [[$autocenter]] when compiling custom gibs to fix potential lighting oddities.}}
{{tip|Use [[$autocenter]] when compiling custom gibs to fix potential lighting oddities such as the gib randomly turning pitch black while rotating/moving around.}}
{{tip|Gibs inherit the skin of the parent model. So as long as the parent model and the gib model have the same amount of skins defined, the gibs will spawn using the same skin.}}


== Example ==
== Examples ==


  $collisiontext
  $collisiontext
  {  
  {  
  break { model mycustomgib1 health 25 fadetime 0 }
  break { model mycustomgib1 health 0 }
  break { ragdoll mycustomgib2 health 10 fadetime 30 debris 1 burst 50 }
  break { ragdoll mycustomgib2 health 25 fadetime 15 debris 1 burst 300 }
  break { model mycustomgib3 health 10 fadetime 30 fademindist 20 fademaxdist 30 }
  break { model mycustomgib3 health 10 fadetime 30 fademindist 20 fademaxdist 30 }
  break { model mycustomgib4 health 10 fadetime 20 offset -2 3.68 12.4 }
  break { model mycustomgib4 health 10 fadetime 20 offset -2 3.68 12.4 }
}
$collisiontext
{
break
{
"model" "mycustomgib1"
"health" "0"
}
break
{
"ragdoll" "mycustomgib2"
"health" "25"
"fadetime" "15"
"debris" "1"
"burst" "300"
}
break
{
"model" "mycustomgib3"
"health" "10"
"fadetime" "30"
"fademindist" "20"
"fademaxdist" "30"
}
break
{
"model" "mycustomgib4"
"health" "10"
"fadetime" "20"
"offset" "-2 3.68 12.4"
}
  }
  }


Line 16: Line 52:


; <code>model <path\name></code>
; <code>model <path\name></code>
: The (compiled) model path to spawn as a gib. Make sure the model used as a gib is properly setup to work as a physics prop.
; <code>ragdoll <path\name></code>
; <code>ragdoll <path\name></code>
: The (compiled) model to spawn.
: The (compiled) model path to spawn as a ragdoll.
; <code>offset <[[Vector]]></code>
; <code>offset <[[Vector]]></code>
: Offsets the current gib. Values are in [[unit]]s.
: Offsets the current gib. Values are in [[unit]]s.
Line 23: Line 60:
: Overrides the model's own health value "This sometimes has to be placed in the [[$keyvalues]] line."
: Overrides the model's own health value "This sometimes has to be placed in the [[$keyvalues]] line."
; <code>fadetime <[[float]]|seconds></code>
; <code>fadetime <[[float]]|seconds></code>
: Time before gibs start to fade away. They are removed once the fade is complete.
: Time before gibs start to fade away. They are removed once the fade is complete. Setting this will also set the gib to not collide with dynamic objects (however it can be overriden by <code>debris</code> option).
: {{TODO|Is there any way to specify how long the fade should last?}}
; <code>fademindist <[[float]]|units></code>
; <code>fademindist <[[float]]|units></code>
: Distance from the camera at which to start rendering the gib.
; <code>fademaxdist <[[float]]|units></code>
; <code>fademaxdist <[[float]]|units></code>
: Distance from the camera at which to start and end temporary fading out of the gib.
: Distance from the camera at which to stop rendering the gib.
; <code>debris <[[bool]]></code>
; <code>debris <[[bool]]></code>
: Prevents the gib model from colliding with dynamic objects when made true. Strongly recommended for anything small.
: Prevents the gib model from colliding with dynamic objects when made true. It is strongly recommended to be enabled for any small gibs.
; <code>burst <[[float]]></code>
; <code>burst <[[float]]></code>
: Adds force to the gib, pushing it outward when the parent model breaks.
: Adds force, in units per second, to the gib, pushing it outward when the parent model breaks. This is useful if you want to make gibs go flying further away from the origin. Not defining this can lead into gibs simply falling flat to the ground. If <code>$autocenter</code> wasn't used, it will apply the force from the center of the gib piece instead of the parent model's origin.
: {{bug|Doesn't seem to work with small gibs, even at very large values.}}
: {{bug|Doesn't seem to work with very tiny gibs, even at very large values.}}
: {{TODO|What units are in use here? Hypothetically this can be found out by using the parameter on a model and measuring how long a gib takes to go from it's spawning position to a point B. It's probably hammer units per second, though.}}
; <code>placementbone <bone></code>
; <code>placementbone <bone></code>
: If set to a bone name, it will spawn the gib at the bone's origin.
; <code>placementattachment <attachment></code>
; <code>placementattachment <attachment></code>
: {{TODO|Compared to [[$autocenter]]'s "placementOrigin" ?}}
: If set to an attachment name, it will spawn the gib at the attachment's position.
; <code>motiondisabled <bool></code>
; <code>motiondisabled <bool></code>
: Disables motion of gib if true.
: Disables all movement, motion, of the gib if enabled.
; <code>multiplayer_break <[[string]]></code>
; <code>multiplayer_break <[[string]]></code>
: If set to <code>server</code>, the gib will not be spawned by the client. If set to <code>client</code>, the gib will not be spawned by the server. By default, both paths are allowed.
: If set to <code>server</code>, the gib will not be spawned by the client. If set to <code>client</code>, the gib will not be spawned by the server. By default, both paths are allowed.
; <code>velocity <[[Vector]]></code>
; <code>velocity <[[Vector]]></code>
: Applys velocity to the gib. Default is 0 0 0 (no velocity)
: Applies velocity to the gib. The default value is <code>0 0 0</code> (no velocity).


== See also ==
== See also ==

Revision as of 22:39, 10 August 2023

$collisiontext defines a breakable model's custom gibs. (Generic gibs are defined by $keyvalues > prop_data > breakable_model).

Tip.pngTip:Use $autocenter when compiling custom gibs to fix potential lighting oddities such as the gib randomly turning pitch black while rotating/moving around.
Tip.pngTip:Gibs inherit the skin of the parent model. So as long as the parent model and the gib model have the same amount of skins defined, the gibs will spawn using the same skin.

Examples

$collisiontext
{ 
	break { model	mycustomgib1	health 0 }
	break { ragdoll	mycustomgib2	health 25	fadetime 15	debris 1	burst 300 }
	break { model	mycustomgib3	health 10	fadetime 30	fademindist 20	fademaxdist 30 }
	break { model	mycustomgib4	health 10	fadetime 20	offset -2 3.68 12.4 }
}
$collisiontext
{ 
	break
	{
		"model"	"mycustomgib1"
		"health" "0"
	}

	break
	{
		"ragdoll" "mycustomgib2"
		"health" "25"
		"fadetime" "15"
		"debris" "1"
		"burst" "300"
	}

	break
	{
		"model"	"mycustomgib3"
		"health" "10"
		"fadetime" "30"
		"fademindist" "20"
		"fademaxdist" "30"
	}

	break
	{
		"model"	"mycustomgib4"
		"health" "10"
		"fadetime" "20"
		"offset" "-2 3.68 12.4"
	}
}

Options

model <path\name>
The (compiled) model path to spawn as a gib. Make sure the model used as a gib is properly setup to work as a physics prop.
ragdoll <path\name>
The (compiled) model path to spawn as a ragdoll.
offset <Vector>
Offsets the current gib. Values are in units.
health <float>
Overrides the model's own health value "This sometimes has to be placed in the $keyvalues line."
fadetime <float|seconds>
Time before gibs start to fade away. They are removed once the fade is complete. Setting this will also set the gib to not collide with dynamic objects (however it can be overriden by debris option).
fademindist <float|units>
Distance from the camera at which to start rendering the gib.
fademaxdist <float|units>
Distance from the camera at which to stop rendering the gib.
debris <bool>
Prevents the gib model from colliding with dynamic objects when made true. It is strongly recommended to be enabled for any small gibs.
burst <float>
Adds force, in units per second, to the gib, pushing it outward when the parent model breaks. This is useful if you want to make gibs go flying further away from the origin. Not defining this can lead into gibs simply falling flat to the ground. If $autocenter wasn't used, it will apply the force from the center of the gib piece instead of the parent model's origin.
Icon-Bug.pngBug:Doesn't seem to work with very tiny gibs, even at very large values.  [todo tested in ?]
placementbone <bone>
If set to a bone name, it will spawn the gib at the bone's origin.
placementattachment <attachment>
If set to an attachment name, it will spawn the gib at the attachment's position.
motiondisabled <bool>
Disables all movement, motion, of the gib if enabled.
multiplayer_break <string>
If set to server, the gib will not be spawned by the client. If set to client, the gib will not be spawned by the server. By default, both paths are allowed.
velocity <Vector>
Applies velocity to the gib. The default value is 0 0 0 (no velocity).

See also