Particles on models: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
No edit summary
(cleanup, corrections)
Line 1: Line 1:
Particle Effects can be attached to models by adding a "particles" section the model's [[.qc]] file. Particles specified in this manner will be created whenever an entity [[SetModel()|switches to using the model]]. This usually occurs when an entity is spawned for the first time, but can also happen when an entity dynamically switches models.
Particles can be '''attached to models''' with the [[$keyvalues]] QC command. Adding a <code>particles</code> section to it allows any number of effects to spawn on the model, and optionally to follow it around.
{{note|does not with with prop_static's.}}


Within the .qc's [[$keyvalues]] section, the format is as follows:
{{note|Particles will not appear if the model is used with [[prop_static]].}}
 
{{tip|To attach particles to models programmatically, see [[Particles In Code]].}}
 
== Syntax ==
 
Within the [[$keyvalues]] block:


  particles
  particles
Line 17: Line 22:


;<code>name</code>
;<code>name</code>
:Must match the name of one of the [[.pcf]] files in the <code>particles/</code> directory.
:The name of a particle system. NOT the name of a .pcf file!
;<code>attachment_type</code>
;<code>attachment_type</code>
:Must match one of the valid attachment types. These are:
:Must match one of the valid attachment types. These are:
:;<code>start_at_origin</code>
:;<code>start_at_origin</code>
:::The particle effect is created at the [[origin]] of the entity it's attached to. The effect doesn't move.
:;<code>start_at_attachment</code>
:;<code>start_at_attachment</code>
:::The particle effect is created on an [[attachment]] point on the entity it's attached to. The effect doesn't move.
::The effect spawns at the [[origin]] or an [[attachment]] of the model. After this, it moves independently. Good for very short effects like explosions or blood spurts.
:;<code>follow_origin</code>
:;<code>follow_origin</code>
:::The particle effect is created at the origin of the entity it's attached to. The effect is updated to move with the entity's origin.
:;<code>follow_attachment</code>
:;<code>follow_attachment</code>
:::The particle effect is created on an attachment point on the entity it's attached to. The effect is updated to move with the attachment point.  
::The effect spawns at the origin or an attachment of the model. After this it follows the origin/attachment, rotating and moving to maintain its relative position. Good for long-term emmisive effects like smoke or trails.
;<code>attachment_point</code>
;<code>attachment_point</code>
:Must match the name of an attachment point in the model. This field is only needed if the <code>attachment_type</code> is one that uses an attachment point.
:An optional attachment point at which the particle system should spawn.


When you attach a particle effect to "start_at..." it will spawn immediately at the origin or the attachment.
From the point of view of the particle effect, you can use several initialisers and operators which will affect how it behaves if it is set to follow an attachment or an origin. The motion of the particles can "follow" the control point by using the movement lock to control point operator. <!--You can also use the Position on Model Random to spawn the effect dynamically across the model.-->
If you attach it to follow, the control point will be updated every frame. The first is better for explosions or one time effects, and the second is better for long term effects like smoke or fire.
From the point of view of the particle effect you can use several initialisers and operators which will affect how it behaves if it is set to follow an attachment or an origin. The motion of the particles can "follow" the control point by using the movement lock to control point operator. You can also use the Position on Model Random to spawn the effect dynamically across the model.


[[Category:Particle System]]
[[Category:Particle System]]
[[Category:QC Keyvalues]]
[[Category:QC Keyvalues]]

Revision as of 14:55, 18 October 2009

Particles can be attached to models with the $keyvalues QC command. Adding a particles section to it allows any number of effects to spawn on the model, and optionally to follow it around.

Note.pngNote:Particles will not appear if the model is used with prop_static.
Tip.pngTip:To attach particles to models programmatically, see Particles In Code.

Syntax

Within the $keyvalues block:

particles
{
	effect
	{
		name			"<particle effect name>"
		attachment_type		<attachment type>
		attachment_point	<name of attachment point>
	}

	<further effects>
}
name
The name of a particle system. NOT the name of a .pcf file!
attachment_type
Must match one of the valid attachment types. These are:
start_at_origin
start_at_attachment
The effect spawns at the origin or an attachment of the model. After this, it moves independently. Good for very short effects like explosions or blood spurts.
follow_origin
follow_attachment
The effect spawns at the origin or an attachment of the model. After this it follows the origin/attachment, rotating and moving to maintain its relative position. Good for long-term emmisive effects like smoke or trails.
attachment_point
An optional attachment point at which the particle system should spawn.

From the point of view of the particle effect, you can use several initialisers and operators which will affect how it behaves if it is set to follow an attachment or an origin. The motion of the particles can "follow" the control point by using the movement lock to control point operator.