Particles on models

From Valve Developer Community
Revision as of 21:12, 9 October 2009 by Empty (talk | contribs)
Jump to navigation Jump to search

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 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.

Note.pngNote:does not with with prop_static's.

Within the .qc's $keyvalues section, the format is as follows:

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

	<further effects>
}
name
Must match the name of one of the .pcf files in the particles/ directory.
attachment_type
Must match one of the valid attachment types. These are:
start_at_origin
The particle effect is created at the origin of the entity it's attached to. The effect doesn't move.
start_at_attachment
The particle effect is created on an attachment point on the entity it's attached to. The effect doesn't move.
follow_origin
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.
follow_attachment
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.
attachment_point
Must match the name of an attachment point in the model. This field is only needed if the attachment_type is one that uses an attachment point.

When you attach a particle effect to "start_at..." it will spawn immediately at the origin or the attachment. 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.