Skip to content

Particle effects

A particle emitter is an entity with a ParticleEmitter component that spawns, moves and draws particles, such as sparks, smoke or fire. Companion components on the same entity each do one job: when particles spawn, where they appear, how they start moving, what pushes them, what they bounce off, and how they look. A particle effect is an entity with a ParticleEffect component that runs the emitters below it under one random seed and one clock.

An emitter or an effect is always its own child entity. It has no position, shape or physics body of its own and follows the part above it:

  • A part
    • an emitter (ParticleEmitter and its companions), or
    • an effect (ParticleEffect)
      • one or more emitters

Prefabs.Spawn("ParticleEmitter") makes a ready emitter that sprays 20 Spark particles a second once its Parent is a part or an effect. To build one, list its components and their starting fields in one World.Spawn table, or add them with Entity:Add and set their fields through their views:

-- Server script in a campfire part: rising sparks.
World.Spawn({
    ParticleEmitter = {
        Lifetime = NumberRange.new(0.5, 1.5),
        Color = Vector3.new(4, 1.5, 0.3), -- above 1 glows
    },
    ParticleSpawnRate = {},
    ParticleShapeSphere = {},
    ParticleVelocityCone = {},
    ParticleGravity = { Scale = -0.5 }, -- negative rises
    ParticleSprite = {},
    Parent = self,
})

Field values

A write outside the bounds in the tables below is an error that names the field and the bounds.

  • A range field, such as Lifetime or Speed, takes a NumberRange, and each particle draws its own value between the two ends. A plain number sets both ends.
  • A curve over a particle's life takes a NumberCurve or a ColorCurve, from 0 at birth to 1 at death. A plain number or color sets one value for the whole life.
  • A texture field takes an asset id as a decimal string or the path of a texture in the project.
  • A Mask or Layers field is a set of 32 bits. An emitter and a world entity act on each other when their fields share a bit; the default of 1 on both sides matches.

ParticleEffect

Field Bounds Default Meaning
Seed 0 to 4294967295 1 Picks the random numbers of every emitter under the effect; the same seed replays the same particles.
TimeScale 0 to 4 1 Speed of the whole effect; 0 freezes it and 2 plays it twice as fast.
CullDistance 1 to 2000 300 The effect is not drawn beyond this many units from the camera.

ParticleEmitter

Field Bounds Default Meaning
Capacity 1 to 16384 256 Most particles alive at once; a spawn past it is dropped.
Space World or Local World World leaves live particles behind as the emitter moves; Local moves them with it.
Lifetime 0.01 to 60 1 to 2 Seconds each particle lives.
Size 0.001 to 50 0.1 to 0.2 Starting size of each particle in units.
Color 0 to 64 per axis Vector3.new(1, 1, 1) Linear red, green and blue of every particle; above 1 glows.

Spawning

Spawn components decide when particles appear. An emitter may have several, such as a steady stream with a burst on top.

  • ParticleSpawnRate spawns a steady stream.
  • ParticleSpawnBurst spawns a burst every Interval seconds.
  • ParticleSpawnOnce spawns one burst when the effect starts playing.
  • ParticleSpawnDistance spawns particles along the path the emitter moves, for a trail behind a moving part.
  • ParticleOnCollision spawns particles where the particles of its Source emitter hit something, such as splashes where rain lands.
  • ParticleOnDeath spawns particles where the particles of its Source emitter die, such as a firework shell that bursts into sparks.
  • ParticleTrail makes every particle of its Source emitter drop these particles behind it as it moves.
Field Bounds Default Meaning
ParticleSpawnRate.Rate 0 to 5000 20 Particles a second.
ParticleSpawnBurst.Count 0 to 5000 20 to 30 Particles in each burst.
ParticleSpawnBurst.Interval 0.05 to 600 1 Seconds between bursts.
ParticleSpawnOnce.Count 0 to 5000 20 to 30 Particles in the burst.
ParticleSpawnDistance.Spacing 0.01 to 100 0.1 Units the emitter travels between two particles.
ParticleSpawnDistance.MaxPerStep 1 to 1000 16 Most particles one step spawns, however far the emitter jumped.
ParticleOnCollision.Source another emitter nil The emitter whose particle collisions spawn these.
ParticleOnCollision.Count 0 to 64 1 to 2 Particles spawned per collision.
ParticleOnCollision.InheritVelocity 0 to 1 0 Share of the source particle's velocity a new particle takes.
ParticleOnDeath.Source another emitter nil The emitter whose dying particles spawn these.
ParticleOnDeath.Count 0 to 64 1 to 2 Particles spawned per death.
ParticleOnDeath.InheritVelocity 0 to 1 0 Share of the source particle's velocity a new particle takes.
ParticleTrail.Source another emitter nil The emitter whose particles leave this trail.
ParticleTrail.Spacing 0.01 to 100 0.1 Units a source particle travels between two trail particles.

Source takes an entity, which must be another live emitter; see placement rules. Assigning nil clears it.

-- Server script in a launcher part: a shell every 3 seconds bursts into sparks.
local shell = World.Spawn({
    ParticleEmitter = {},
    ParticleSpawnBurst = { Count = NumberRange.new(1), Interval = 3 },
    ParticleShapeSphere = {},
    ParticleVelocityCone = { Speed = NumberRange.new(25, 30) },
    ParticleGravity = {},
    ParticleSprite = {},
    Parent = self,
})

World.Spawn({
    ParticleEmitter = {},
    ParticleOnDeath = { Source = shell, Count = NumberRange.new(40, 60) },
    ParticleVelocityCone = { Angle = 180 },
    ParticleGravity = {},
    ParticleSprite = {},
    Parent = self,
})

Shapes

A shape decides where new particles appear, measured from the emitter. An emitter has at most one shape: ParticleShapeSphere spawns in a ball, ParticleShapeBox in a box, and ParticleShapeCylinder in an upright cylinder.

Field Bounds Default Meaning
ParticleShapeSphere.Offset -100 to 100 per axis Vector3.new(0, 0, 0) Center of the sphere from the emitter, in units.
ParticleShapeSphere.Radius 0 to 100 0.5 Radius in units.
ParticleShapeSphere.Thickness 0 to 1 1 Share of the radius, from the surface in, that spawns; 0 spawns on the surface, 1 in the whole ball.
ParticleShapeBox.Offset -100 to 100 per axis Vector3.new(0, 0, 0) Center of the box from the emitter, in units.
ParticleShapeBox.Size 0 to 100 per axis Vector3.new(1, 1, 1) Full size of the box on each axis, in units.
ParticleShapeCylinder.Offset -100 to 100 per axis Vector3.new(0, 0, 0) Center of the cylinder from the emitter, in units.
ParticleShapeCylinder.Radius 0 to 100 0.5 Radius in units.
ParticleShapeCylinder.Height 0 to 100 1 Height along its Y axis, in units.

Starting motion

These components set up each particle once, when it spawns. ParticleVelocityCone launches it in a random direction inside a cone, and ParticleRotation gives it a starting rotation and a spin.

Field Bounds Default Meaning
ParticleVelocityCone.Direction -1 to 1 per axis Vector3.new(0, 1, 0) Axis of the cone.
ParticleVelocityCone.Angle 0 to 180 20 Half-angle of the cone in degrees; 0 is a straight line and 180 fills a sphere.
ParticleVelocityCone.Speed 0 to 500 1 to 2 Launch speed in units a second.
ParticleRotation.Angle -360 to 360 0 to 360 Starting rotation in degrees.
ParticleRotation.Spin -1440 to 1440 -30 to 30 Spin in degrees a second.

Forces and changes over life

These components act on every live particle at every step.

  • ParticleGravity pulls particles down with a scaled gravity and adds a fixed acceleration.
  • ParticleCurlNoise stirs particles through a swirling noise field, as smoke and dust move.
  • ParticleVortex swings particles around an axis through the emitter.
  • ParticleDrag slows particles down.
  • ParticleWind pulls particles toward the velocity of the air.
  • ParticleAttractors lets ParticleAttractorSphere entities pull the particles; see world colliders and attractors.
  • ParticleColorRamp colors and fades each particle over its life.
  • ParticleSizeCurve grows or shrinks each particle over its life.
  • ParticleStretch stretches fast particles along their velocity, for rain and streaks.
Field Bounds Default Meaning
ParticleGravity.Scale -4 to 4 1 Pulls down at Scale times minus World.Gravity.Y / 20 units a second squared, which is 9.81 at the default -196.2; negative values make particles rise.
ParticleGravity.Acceleration -1000 to 1000 per axis Vector3.new(0, 0, 0) Added acceleration along the world axes in units a second squared, the same at any World.Gravity.
ParticleCurlNoise.Strength 0 to 50 1 Acceleration of the swirl.
ParticleCurlNoise.Frequency 0.01 to 20 1 Swirls per unit; higher is finer.
ParticleCurlNoise.Scroll -50 to 50 per axis Vector3.new(0, 0, 0) Units a second the noise field drifts.
ParticleVortex.Axis -1 to 1 per axis Vector3.new(0, 1, 0) Axis the particles circle.
ParticleVortex.Strength -50 to 50 1 Speed gained around the axis each second; a negative value turns the other way.
ParticleVortex.Pull -50 to 50 0 Speed gained toward the axis each second; a negative value pushes out.
ParticleDrag.Coefficient 0.01 to 50 1 Speed falls by a factor of e every 1/Coefficient seconds.
ParticleWind.Velocity -100 to 100 per axis Vector3.new(1, 0, 0) Velocity of the air in units a second.
ParticleWind.Response 0.01 to 50 1 How fast particles take up the velocity of the air.
ParticleAttractors.Mask 0 to 4294967295 1 Feels the ParticleAttractorSphere entities whose Layers share a bit.
ParticleColorRamp.Color 0 to 64 ColorCurve.linear(Color.White) Tint over each particle's life, multiplied by the emitter Color.
ParticleColorRamp.Opacity 0 to 1 NumberCurve.linear(1, 0) Opacity over each particle's life; the default fades out.
ParticleSizeCurve.Curve 0 to 100 NumberCurve.linear(1, 0) Multiple of the starting size over each particle's life; the default shrinks to nothing.
ParticleStretch.SpeedScale 0 to 10 0.3 Extra length along the velocity for each unit a second of speed.
ParticleStretch.MaxRatio 1 to 50 4 Longest a particle gets, as a multiple of its width.

Effects made before Acceleration existed pull as they did, because Acceleration defaults to zero. For particles that fall the way parts do, set Scale to 0 and Acceleration to World.Gravity. Acceleration keeps its value when World.Gravity changes, so set it again after each change.

-- Server script in a part: drops that fall the way parts do.
World.Spawn({
    ParticleEmitter = {},
    ParticleSpawnRate = {},
    ParticleGravity = { Scale = 0, Acceleration = World.Gravity },
    ParticleSprite = {},
    Parent = self,
})

Collisions

  • ParticleCollision bounces particles off ParticleColliderPlane entities; see world colliders and attractors.
  • ParticleDepthCollision bounces particles off the scene each player sees, with no collider entities to place.
  • ParticleKillOnContact kills a particle after a number of collisions.
Field Bounds Default Meaning
ParticleCollision.Mask 0 to 4294967295 1 Hits the ParticleColliderPlane entities whose Layers share a bit.
ParticleCollision.Bounce 0 to 1 0.3 Share of the speed kept off a hit; 0 stops dead and 1 bounces back at full speed.
ParticleCollision.Friction 0 to 1 0.3 Share of the sliding speed lost on a hit.
ParticleCollision.LifetimeLoss 0 to 1 0 Share of its life a particle loses on each hit.
ParticleDepthCollision.Thickness 0.01 to 10 0.1 How deep behind a visible surface a particle still hits it, in units.
ParticleDepthCollision.Bounce 0 to 1 0.3 Share of the speed kept off a hit.
ParticleDepthCollision.Friction 0 to 1 0.3 Share of the sliding speed lost on a hit.
ParticleKillOnContact.Contacts 1 to 255 1 Collisions after which the particle dies.

Drawing

  • ParticleSprite draws each particle as a flat textured square.
  • ParticleFlipbook plays the sprite texture as a grid of animation frames, such as the 8 by 8 Fire Loop ("72057594037932757") and Smoke Puff ("72057594037932758"). Studio's Select Texture lists these and the Spark under Particles.
  • ParticleLit shades the particles by the lights around them, for smoke and dust that should not glow.
  • ParticleRibbon draws a strip through the particles of each trail.
  • ParticleLight lets some particles light the scene around them.
Field Bounds Default Meaning
ParticleSprite.Texture a texture "72057594037932759" The image on every particle; "0" draws a soft round dot.
ParticleSprite.Facing see below Camera How each square turns.
ParticleSprite.Blend see below Additive How each square mixes with what is behind it.
ParticleSprite.Emissive 0 to 64 1 Brightness multiplier of the image.
ParticleFlipbook.Columns 1 to 16 8 Frames across the sprite texture.
ParticleFlipbook.Rows 1 to 16 8 Frames down the sprite texture.
ParticleFlipbook.Cycles 0 to 20 1 Times the animation plays over each particle's life.
ParticleFlipbook.StartFrame 0 to 1 0 to 0 Where each particle starts, as a share of the frames.
ParticleLit.Influence 0 to 4 1 How much the scene lights shade the particles.
ParticleRibbon.Texture a texture "0" The image along the ribbon; "0" draws it plain.
ParticleRibbon.Width 0.001 to 50 0.1 Width of the ribbon in units.
ParticleRibbon.TileLength 0.01 to 100 1 Units of ribbon that one repeat of the texture covers.
ParticleLight.MaxLights 0 to 64 4 Most particles of this emitter that cast light.
ParticleLight.Radius 0.05 to 20 1 Reach of each light in units.
ParticleLight.Intensity 0 to 10 1 Brightness of each light.

Facing takes one of these names:

  • Camera turns the square to face the camera.
  • CameraWorldUp turns the square to face the camera and keeps it upright.
  • VelocityRoll stands the square along the particle's velocity and turns it around that line toward the camera.
  • VelocityPerpendicular lays the square across the particle's velocity, so it faces the way the particle travels.
  • Fixed keeps the orientation of the emitter.

Blend takes one of these names:

  • Additive adds the particle's light to the scene behind it, so particles glow, as fire and sparks do.
  • AlphaByDepth and AlphaBySpawnOrder cover the scene behind each particle by its opacity, for smoke and dust, with particles sorted by distance from the camera or by spawn order.
  • Cutout draws only solid pixels, with no partial transparency.

World colliders and attractors

Two components go on ordinary world entities, such as a part, never on an effect or an emitter:

  • ParticleColliderPlane is a flat plane through the entity's Position, facing its up axis, that particles of a ParticleCollision emitter bounce off.
  • ParticleAttractorSphere is a ball around the entity's Position that pulls the particles of a ParticleAttractors emitter.
Field Bounds Default Meaning
ParticleColliderPlane.Layers 0 to 4294967295 1 Hit by the ParticleCollision emitters whose Mask shares a bit.
ParticleAttractorSphere.Layers 0 to 4294967295 1 Pulls the ParticleAttractors emitters whose Mask shares a bit.
ParticleAttractorSphere.Strength -50 to 50 1 Acceleration toward the center; a negative value pushes away.
ParticleAttractorSphere.Radius 0.05 to 100 2 Reach of the pull in units.

Placement rules

The engine refuses an edit that breaks one of these rules, from a script, from Studio or from the server. A refused Entity:Add call adds none of its components, and the error names the rule, as in Entity:Add: ParticleSpawnRate needs a ParticleEmitter on the same entity.

  1. An effect or an emitter is its own child entity, never on a part, an interface element or another entity.
  2. Every spawn, shape, motion, force, collision and drawing component needs a ParticleEmitter on the same entity, already there or in the same World.Spawn call.
  3. An emitter has one shape. Remove the old shape before you add another.
  4. ParticleEffect and ParticleEmitter go on separate entities; parent the emitters to the effect.
  5. ParticleColliderPlane and ParticleAttractorSphere go on a world entity, never on an effect or an emitter.
  6. Scripts and Studio never add ParticleEffectControl or ParticleEmitterControl; the engine writes them.
  7. A ParticleEmitter cannot be removed while a companion remains. Destroy the entity instead.
  8. A Source must name another live emitter and must not close a cycle of emitters, such as two emitters that each spawn from the other.