ParticleEmissionRate emitter,particles_per_second#
Parameters
|
emitter - CPU or GPU particle emitter entity particles_per_second# - new particles spawned each second; 0 stops continuous emission. Negative values are treated as 0 |
Description
|
Sets how many particles an emitter spawns per second. This is the tap for a continuous effect: a campfire, a smoking wreck, a dust plume behind a car. Fractional rates work, because the emitter keeps a running remainder - a rate of 0.5 gives you one particle every two seconds rather than none at all. Set the rate to 0 for effects that only exist as bursts, such as impact sparks or a puff of debris, and drive them with EmitParticles instead. That is exactly what the sparks preset does. Rate and lifetime together decide how busy the effect looks: roughly rate multiplied by ParticleLifetime particles will be alive at any moment. If that product is larger than the emitter maximum, the extra particles are never spawned and the effect just stops growing, so raise ParticleMax to match. Gotcha: "per second" means per second of simulated time, and simulated time comes from UpdateWorld. The default UpdateWorld tick advances one 60 Hz step, so the rate only matches real seconds if you call UpdateWorld about 60 times a second. A paused emitter spawns nothing at all. Requires Extended mode. See also: EmitParticles, ParticleLifetime, ParticleMax, PauseParticles, ParticlePreset. |
Example
; ParticleEmissionRate Example ; ---------------------------- ; Requires Extended mode. Graphics3D 640,480,0,2 SetBuffer BackBuffer() camera=CreateCamera() PositionEntity camera,0,2,-6 CameraClsColor camera,8,12,24 floor=CreatePlane() EntityColor floor,30,34,44 ; A cottage chimney venting smoke chimney=CreateCylinder() ScaleEntity chimney,0.3,1,0.3 PositionEntity chimney,0,1,0 EntityColor chimney,90,70,60 ; Smoke emitter above the chimney emitter=CreateParticleEmitter(800) PositionEntity emitter,0,2,0 ParticleLifetime emitter,3,4 ParticleVelocity emitter,0,1,0,0.4,0.3,0.4 ParticleColor emitter,180,180,190,0.8,120,120,130,0 ParticleSize emitter,0.1,0.5,0.3 EntityBlend emitter,2 rate=60 While Not KeyDown(1) ; [ / ] change the continuous emission rate (0 stops emission) If KeyDown(26) And rate>0 Then rate=rate-1 If KeyDown(27) And rate<300 Then rate=rate+1 ; Emit this many smoke puffs per second ParticleEmissionRate emitter,rate ; Arrow keys move the camera If KeyDown(200) Then MoveEntity camera,0,0,0.1 If KeyDown(208) Then MoveEntity camera,0,0,-0.1 If KeyDown(203) Then TurnEntity camera,0,1,0 If KeyDown(205) Then TurnEntity camera,0,-1,0 ; UpdateWorld also advances the particle simulation UpdateWorld RenderWorld Text 0,0,"Arrow keys: move camera [ / ] : emission rate Esc: exit" Text 0,20,"ParticleEmissionRate emitter,"+rate Text 0,40,"Live particles: "+CountParticles(emitter) Flip Wend End
Index