A ParticleEmitter is an instance that emits 2D images (particles) that look and behave for the duration of their lifetime according to the particle emitter's set properties. You can customize a particle emitter's properties to create special effects like fire, smoke, and sparks.
You can parent a particle emitter to an Attachment or an object of the BasePart class. When you parent a particle emitter to a BasePart, the particles generate and emit based on that parent's size. For example, a part with a small area compacts particles, while a part with a large area spreads particles out.
Additionally, the EmissionDirection property determines the face (NormalId) of the BasePart that emits particles. When you change this property, you consequently change the particle emission direction as well.
Creating a Particle Emitter
To create a particle emitter on a given BasePart or Attachment:
- In the Explorer window, hover over the part or attachment and click the ⊕ button. A contextual menu displays.
- From the menu, insert a ParticleEmitter. The particle emitter immediately emits particles within the part's area or from the attachment's position.
You can change the properties of particle emitters to create interesting visual effects such as glowing portals, green billowing smoke, or vibrant explosions.
The Texture property renders the image that each particle displays. By default, particle emitters have particles with a white sparkle texture, but you can change it to any texture to achieve interesting effects.
When you are creating a texture to use as a particle, consider these best practices:
- Use images in .png format with a background that is transparent. If your texture is grayscale with no alpha channel, try setting the particle emitter's LightEmission property to 1 to hide the darker regions.
- Make your image grayscale to give yourself full control over the final color of particles with the Color property.
To insert an image into a particle emitter:
If you want to insert an image that you have previously imported, click the Inventory tab. If you want to insert an image from another creator, click the Marketplace tab.
Right-click on the image you want to insert into a particle emitter. A pop-up menu displays.
Select Copy Asset ID.
In the Explorer window, select a ParticleEmitter.
In the Properties window, paste the asset ID into the Texture property.
The Lifetime property sets the lifetime of a particle in seconds. You can set this property either as a consistent value, or provide a Min and Max range from which a random lifetime will be chosen for each particle.
The Color property tints the particle's texture to either a specific hue or a ColorSequence data type. A color sequence changes a particle's color across its lifetime.
To set particles to a specific hue:
In the Explorer window, select the ParticleEmitter.
In the Properties window, select the Color property. You can either:
- Click on the color square to open the Colors pop-up window and select a color.
- Input three numbers into the RGB color value field.
To set a particle emitter's color sequence:
In the Explorer window, select the ParticleEmitter.
In the Properties window, select the Color property.
Click the ... button. A color sequence pop-up displays. By default, the color sequence is all white.
Each triangle on the bottom axis of the color sequence is a keypoint that determines the color value of the property at that point of the particle's lifetime.
Click the keypoint at the start of the color sequence, then click the small square next to Color to open the Colors pop-up window.
Select the color that you want particles to be at the start of their lifetime.
If you want particles to change their color near the end of their lifetime, click the keypoint at the end of the color sequence, then click the small square next to Color to open the Colors pop-up window to select a color.
If applicable, you can:
- Add another keypoint by clicking anywhere on the graph.
- Make a color change sooner or later within the gradient by dragging an existing keypoint to a new position. color to change sooner or later within the gradient.
- Delete a keypoint by selecting it and clicking the Delete button.
- Reset the sequence by clicking the Reset button.
The Size property sets the stud size of each particle either as a consistent size or a NumberSequence. A number sequence changes a particle's size across its lifetime; it starts at 0, the start of emitting, and ends at 1, the lifetime of a particle.
To set particles to a specific size:
- In the Explorer window, select the ParticleEmitter.
- In the Properties window, select the Size property.
- Input the stud size that you want each particle to be.
To set a particle emitter's number sequence:
In the Explorer window, select the ParticleEmitter.
In the Properties window, select the Size property.
Click the … button. A number sequence pop-up displays. By default, the graph is a straight line and a particle remains the same size throughout its lifetime.
Each square at the start and end of the number sequence is a keypoint that determines the size value of the property at that point of the particle's lifetime.
Perform one of the following actions:
- To change the size at a point, click on a keypoint and either drag it up or down, or enter a value in the Value field.
- To insert new keypoints, click on any point in the graph.
- To delete a keypoint, select the keypoint, then the Delete button.
- To add a random range for size, click on any keypoint and drag the envelope lines up or down. At that time, particles generate at a random size between the pink envelope.
The Transparency property sets the opacity of each particle either as a consistent opacity or a NumberSequence. A number sequence changes a particle's opacity across its lifetime; it can range anywhere from 0 (totally opaque) to 1 (fully clear). For details on how to set particles to either a specific opacity or to a number sequence, follow the instructions in customizing Size.
The Transparency property is one of the most vital properties of a particle emitter. Fading particles near the start and/or end of their lifetime avoids a popping in/out effect and provides a more realistic effect.
The Rate property sets the number of particles that emit per second. A single particle emitter can create up to 500 particles per second. For best performance, keep the particle rate as low as possible. Experiment with the size of the particle texture, the size of particles, and other properties to minimize the number of particles while still achieving the desired visual effect.
The Orientation property determines which orientation mode to use for an emitter's particle geometry.
|FacingCamera||Standard camera-facing billboard quad; default behavior.|
|FacingCameraWorldUp||Facing the camera, but rotating only on the vertical upward world Y axis.|
|VelocityParallel||Aligned parallel to their direction of movement.|
|VelocityPerpendicular||Aligned perpendicular to their direction movement.|
The SpreadAngle property has an X and a Y value which determine the range of angles from which a particle can emit. The range is calculated from both sides around the axes; for example, a value of (45, 0) emits particles from 0° to 45° away from the EmissionDirection across the X axis.
The Shape property sets the shape of the particle emitter to either a Box, Sphere, Cylinder, or Disc.
After you select a shape for your particle emitter, you can experiment with the ShapeStyle, ShapeInOut, and ShapePartial properties to further customize particle emission.
The ShapeStyle property sets the emission type to either:
- Volume — Particles emit anywhere within the shape.
- Surface — Particles only emit from the outside of the shape.
The ShapeInOut property sets the emission as follows:
- Outward — Particles emit away from the shape.
- Inward — Particles emit toward the shape.
- InAndOut — Particles randomly behave as both Inward and Outward.
The ShapePartial property is a factor you can use to determine cylinder, disc, and sphere shapes.
For cylinders, ShapePartial multiplies the radius of the cylinder on the side of its EmissionDirection.
For discs, ShapePartial inversely multiplies the inner radius of the disc.
For spheres, ShapePartial multiplies the hemispherical angle.
Particle flipbook textures let you animate a particle's texture over its lifetime.
To use particle flipbooks, the texture must be a square with dimensions of 8×8, 16×16, 32×32, 64×64, 128×128, 256×256, 512×512, or 1024×1024. If the texture isn't a square with one of these dimensions, then you can't set flipbook's properties in the Properties window. The flipbook texture can have a frame layout of 2×2, 4×4, or 8×8. For example, the following 1024×1024 image has an 8×8 layout, so it's suitable for a 64-frame animation.
When you create a flipbook texture, include spacing between each of the particle frames. Mip filtering issues might lead to needing larger spacing. The previous image has transparent spacing around each particle frame in the flipbook particle texture.
The FlipbookFramerate property determines how fast the flipbook texture animates in frames per second. Like Lifetime, you can set a minimum and maximum range to randomize the framerate of the flip book, with a maximum of 30 frames per second.
The FlipbookLayout property determines the layout of the texture. It can be any value of the ParticleFlipbookLayout enum:
- None — Disable flipbook features and use the texture as a single static texture over the particle's lifetime.
- Grid2x2 — 2×2 frames for a 4-frame animation.
- Grid4x4 — 4×4 frames for a 16-frame animation.
- Grid8x8 — 8×8 frames for a 64-frame animation.
The FlipbookMode property determines the type of the flipbook animation. The property can be any value of the ParticleFlipbookMode enum:
- Loop — Continuously play through all frames, starting back at the first frame after playing the last.
- OneShot — Play through the animation only once across the particle's lifetime. With this setting, the FlipbookFramerate property doesn't apply; instead, the framerate is determined by the particle's Lifetime divided evenly by the number of frames in the animation. OneShot animations are useful for clear non-repeating animations, such as an explosion that creates a puff of smoke and then fades out.
- PingPong — Play from the first to the last frame, then in reverse from the last to the first, repeating throughout the Lifetime of the particle.
- Random — Play the frames in a random order, blending/crossfading from one frame to the next. This can be useful for organic particle textures at low framerates, such as stars slowly twinkling between subtly different shapes.
The FlipbookStartRandom property determines whether each particle begins at a random frame of the animation instead of always starting at the first frame. One use case is to enable this property and also set FlipbookFramerate to zero, causing each emitted particle to be a static frame chosen randomly from the flipbook texture.
To further customize particles, consider the following additional emitter properties, and see the ParticleEmitter reference page for a comprehensive list.
|Acceleration||Determines by how much the velocity of particles changes per second. You can use this property to create effects such as particles being affected by gravity or wind.|
|Drag||Determines the rate in seconds that particles lose half their speed.|
|Rotation||Determines the angle of rotation for newly-emitted particles. Single numbers create particles at that angle, while two numbers (minimum, maximum) set a random rotation for each particle.|
|RotSpeed||Determines the angular speed in degrees per second for particles. This can be a single number or a number range for a randomized speed. Negative values cause particles to rotate counter-clockwise.|
|Speed||Determines the initial speed of particle movement, measured in studs per second. This can be a single number or a number range for a randomized speed. Negative values cause particles to move in reverse.|
|ZOffset||Determines how many studs toward the camera that particles are rendered, allowing for multiple particle emitters to layer properly. The apparent size of the particles isn't changed.|
You can create explosions by pairing a particle emitter with a LocalScript that triggers a burst of particles when a user steps on an object.
To create an explosion:
Create a particle emitter and rename it to Explosion.
Customize the particles to the following listed properties:
- Texture - rbxassetid://6101261905
- Drag - 10
- Lifetime - 0.2, 0.6
- Speed - 20, 40
- SpreadAngle - 180, 180
Under the parent object of the particle emitter, insert a LocalScript object:
- Hover over the part and click the ⊕ button. A contextual menu displays.
- From the menu, insert a LocalScript.
Copy and paste the following code sample which checks if a user has touched the parent object of the particle emitter. When it detects the user, 100 particles emit and the user's health drops to 0.local trapObject = script.Parentlocal particleEmitter = trapObject:FindFirstChild("Explosion")local EMIT_AMOUNT= 100local function killPlayer(otherPart)local character = otherPart.Parentlocal humanoid = character:FindFirstChildWhichIsA("Humanoid")if humanoid thenhumanoid.Health = 0particleEmitter:Emit(EMIT_AMOUNT)endendtrapObject.Touched:Connect(killPlayer)