Particles on models: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
No edit summary
(added note and image about particles on playermodels)
 
(6 intermediate revisions by 4 users not shown)
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.


Within the .qc's [[$keyvalues]] section, the format is as follows:
{{note|Particles will not appear if the model is used with [[prop_static]].}}
{{note|In most cases, particles attached to a player model will end up visible in first person, but relative to where the 3d playermodel would be in that spot. They will also sometimes disappear when the player dies.}}
{{tip|To attach particles to models programmatically, see [[Particles In Code]].}}
[[File:L4d2 particle attachment playermodel.png|400px|thumb|Fire particles in {{L4D2}} which were added to the 3rd person player models wrist. But for some reason they appear in the 1st person where the 3rd person models wrists are.]]
== Syntax ==
 
Within the [[$keyvalues]] block:


  particles
  particles
Line 15: Line 21:
  }
  }


;<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 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.
:::The particle effect is created on an [[attachment]] point on the entity it's attached to. The effect doesn't move.
:; <code>follow_origin</code>
:;<code>follow_origin</code>
:; <code>follow_attachment</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.
:: 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>follow_attachment</code>
; <code>attachment_point</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 attachment point at which the particle system should spawn, if applicable.
;<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.
From the point of view of the particle system, 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.  


{{todo|How are already-emitted particles affected by start/follow?}}
You can also use the [[Position on Model Random]] initializer to spawn the system dynamically across the model.


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

Latest revision as of 11:24, 5 April 2022

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.
Note.pngNote:In most cases, particles attached to a player model will end up visible in first person, but relative to where the 3d playermodel would be in that spot. They will also sometimes disappear when the player dies.
Tip.pngTip:To attach particles to models programmatically, see Particles In Code.
Fire particles in Left 4 Dead 2 which were added to the 3rd person player models wrist. But for some reason they appear in the 1st person where the 3rd person models wrists are.

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
The attachment point at which the particle system should spawn, if applicable.

From the point of view of the particle system, 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 initializer to spawn the system dynamically across the model.