Difference between revisions of "Particles In Code"

From Valve Developer Community
Jump to: navigation, search
 
Line 1: Line 1:
 
[[Category: Particle System]]
 
[[Category: Particle System]]
 +
==Precaching Effects==
 +
 +
Before dispatching effects, you should precache them first:
 +
PrecacheParticleSystem( "your_particle_effect_name" );
 +
 
==Dispatching Effects==
 
==Dispatching Effects==
  

Revision as of 13:13, 9 July 2008

Precaching Effects

Before dispatching effects, you should precache them first: 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.