Particles In Code: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
(rv. searching the source code shows that DispatchParticleEffect is defined in shared code, but only ever used on the client)
(cleanup)
Line 1: Line 1:
[[Category: Particle System]]
== Precaching Effects ==
[[Category: Snippets]]
 
==Precaching Effects==


Before dispatching effects, you should precache them first:
Before dispatching effects, you should precache them first. This can be done by listing them in your code>particles_manifest.txt</code> file, or with this code:


  PrecacheParticleSystem( "your_particle_effect_name" );
<source lang=cpp>PrecacheParticleSystem( "your_particle_effect_name" );</source>
{{note|you can also precache them in your <code>particles_manifest.txt</code> instead}}


==Dispatching Effects==
== Dispatching Effects ==


At the very simplest you can just kick off an effect with the Dispatch function:
At the very simplest you can just kick off an effect with the Dispatch function:


  void DispatchParticleEffect( const char *pszParticleName, Vector vecOrigin, QAngle vecAngles,  
<source lang=cpp>void DispatchParticleEffect( const char *pszParticleName, Vector vecOrigin, QAngle vecAngles,  
                              CBaseEntity *pEntity )
CBaseEntity *pEntity )
  void DispatchParticleEffect( const char *pszParticleName, ParticleAttachment_t iAttachType,  
void DispatchParticleEffect( const char *pszParticleName, ParticleAttachment_t iAttachType,  
                              CBaseEntity *pEntity, int iAttachmentPoint,  
CBaseEntity *pEntity, int iAttachmentPoint,  
                              bool bResetAllParticlesOnEntity  )
bool bResetAllParticlesOnEntity  )</source>


The former signature lets you just place it arbitrarily in world coordinates. The latter permits you to attach it to an entity. You may then stop effects on an entity with this function:
The former signature lets you just place it arbitrarily in world coordinates. The latter permits you to attach it to an entity. You may then stop effects on an entity with this function:


  StopParticleEffects( CBaseEntity *pEntity )
<source lang=cpp>StopParticleEffects( CBaseEntity *pEntity )</source>


You cannot specify a lifetime on a particle system from code. The system will self-terminate after the lifespan specified in the particle definition.
You cannot specify a lifetime on a particle system from code. The system will self-terminate after the lifespan specified in the particle definition.


DispatchParticleEffect particles is only visible to you if run from client-side.
DispatchParticleEffect particles is only visible to you if run from client-side.
[[Category: Particle System]]
[[Category: Snippets]]

Revision as of 02:51, 31 July 2009

Precaching Effects

Before dispatching effects, you should precache them first. This can be done by listing them in your code>particles_manifest.txt file, or with this code:

PrecacheParticleSystem( "your_particle_effect_name" );

Dispatching Effects

At the very simplest you can just kick off an effect with the Dispatch function:

void DispatchParticleEffect( const char *pszParticleName, Vector vecOrigin, QAngle vecAngles, 
				CBaseEntity *pEntity )
void DispatchParticleEffect( const char *pszParticleName, ParticleAttachment_t iAttachType, 
				CBaseEntity *pEntity, int iAttachmentPoint, 
				bool bResetAllParticlesOnEntity  )

The former signature lets you just place it arbitrarily in world coordinates. The latter permits you to attach it to an entity. You may then stop effects on an entity with this function:

StopParticleEffects( CBaseEntity *pEntity )

You cannot specify a lifetime on a particle system from code. The system will self-terminate after the lifespan specified in the particle definition.

DispatchParticleEffect particles is only visible to you if run from client-side.