Particles In Animations: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
No edit summary
Line 38: Line 38:
'''Example of use:'''
'''Example of use:'''


<quote>hi</quote>
<code>
$sequence shoot "shoot" fps 30.00 {
 
{ event AE_CL_CREATE_PARTICLE_EFFECT 34 "weapon_muzzle_flash_assaultrifle_c1 follow_attachment muzzle_flash" }
{ event AE_CL_STOP_PARTICLE_EFFECT 81 "weapon_muzzle_flash_assaultrifle_c1 1" }
 
}
</code>





Revision as of 05:36, 13 April 2012

Particle Effects can be created in animations by using an anim event. Particle effects specified in this manner will be created every time the entity fires that anim event. So if you really want a single particle effect that keeps pumping out particles over time, you want to specify the effect in the model instead.

The anim event is AE_CL_CREATE_PARTICLE_EFFECT. It takes a string parameter that contains the particle effect options, separated by spaces. So, the .qc entry format for this particle effect is as follows:

{ event AE_CL_CREATE_PARTICLE_EFFECT <frame number> "<particle effect name> <attachment type> <attachment point>" }
<particle effect 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 <attachment type> is one that uses an attachment point.


Stopping Particle Effects

From Alien Swarm's provided modelsrc content it is evident that the AE_CL_STOP_PARTICLE_EFFECT exists and was implemented. Not sure if this works in Source2009/Source2007 but this will work in Alien Swarm and above branches of Source.

Now the .qc code for this is as follows:

{ event AE_CL_STOP_PARTICLE_EFFECT <frame number> "<particle effect name> <boolean>" }

OK lets break it down now,

<frame number>
Frame number in the sequence smd that the particle is desired to be destroyed/stopped.
<particle effect name>
Must match the name of one of the .pcf files in the particles/ directory that you created on the model.
<boolean>

1 or 0 to use to tell the definite end of the particle.

Example of use:

$sequence shoot "shoot" fps 30.00 {

{ event AE_CL_CREATE_PARTICLE_EFFECT 34 "weapon_muzzle_flash_assaultrifle_c1 follow_attachment muzzle_flash" } { event AE_CL_STOP_PARTICLE_EFFECT 81 "weapon_muzzle_flash_assaultrifle_c1 1" }

}