Using Prebuilt Particle Emitters
-
Introduction
Emitters allow us to add VFX (visual effects) to our 3D scene, such as fire or light. An emitter could generate a huge number of “particles” (2D images), and these particles can work together to create beautiful visual effects.
It is not easy to master how to use emitters. For a simple start, you can choose from a list of emitters that are built for you, so you only need to customize them based on your needs.
The “Add Prebuilt Emitter” Block
To add a prebuilt emitter, you can use this block in the “3D Effects” category:
Let’s look at the parameters below:
Prebuilt Emitter Type
You can pick the type of emitter you would like to use, such as “fire” or “spark”. We will present examples for each type of emitter in the “Examples” section below.
Color1 and Color2
You can specify 2 colors to customize the emitter. For example, if you are adding a fire emitter, you can use these 2 color inputs to control the inner color and outer color of the fire.
Capacity
This parameter controls how many particles can be alive when you run your program. For example, if the capacity is 100, then you can have at most 100 particles displayed on the stage.
Texture Size
Each particle is simply a 2D image, such as a circle or a star. You can set the size of this image using this input. When each particle is larger, they will more likely overlap with each other, resulting in denser and brighter effects.
Source Size
The particles can be generated from a source location, which can be any random point inside a 3D box. You can change the size of that 3D box using the source size. For example, when the source size is very small, all particles are created around the same position.
Speed
For some effects, the particles need to be moving in a certain direction. You can set the moving speed of these particles using this input. When the speed value is large, the particles will travel further away from the source within the same amount of time.
Max Life
This input controls the maximum lifetime of all the particles in seconds. For example, if the max life is 5, then all particles will die in 5 seconds or shorter.
Name (optional)
The name of the new emitter you are creating. You can use this name to select this emitter later.
The “Start Emitter” Block
After you have added an emitter to the scene, you can use the “start emitter” block to make the emitter spits out particles.
- Emitter Name: the first input is the name of the emitter. You can leave it blank if the emitter is the selected sprite object.
- Generation Method and Count: if “by rate”, then the emitter will keep firing out particles forever, and the third input will be the number of particles emitted per second. if “for one-time count”, then the emitter will only emit the given number of particles, then the emitter will stop until you start it again.
Dragon Fire
This program generates a ray of fire along the Y-axis.
Result
Explanations
- Color1 and Color2: each particle will start in yellow color, then over time its color gradually changes to orange.
- Capacity: This emitter can emit up to 1000 particles each second
- Texture Size: each particle is a 50-by-50 image like this:
-
Source Size: all particles are generated within a small box of size 1 at the origin
-
Speed: each particle will move forward along the Y-axis at a speed of 300 units per second until it dies
-
Max Life: each particle will die within 1 second randomly. For example, one particle might die after 0.5 seconds. It will have traveled by 300 * 0.5 = 150 units when it dies, which means its position will be around Y of 150 when it dies.
-
Firing Rate: the emitter will generate 1000 particles per second. Note that this is a continuous process: when a particle is emitted, the total number of living particles is increased by one. This particle starts to travel forward, and after some time (up to 1 second), it dies. After its death, the total number of living particles is decreased by 1. The emitter will try to keep generating new particles so long as the total number of living particles is not more than its capacity.
Ghost Fire
For comparison, this program generates a ghost fire:
Besides changing the colors, here are some other differences from the dragon fire program:
- Lower Capacity: This emitter only emits up to 20 particles per second
- Smaller Texture: each particle is only 20 by 20
- Slower Speed: each particle can only travel at most 30 units per second, so the fire ray is much shorter
- Rotation: the emitter has been rotated 90 degrees around the X-axis, so the particles will move up along the Z-axis instead
- Emission Rate: the emission rate is 100, which means the emitter will try to emit 100 particles per second. However, since the capacity is only 20, after the first 20 particles are emitted, the emitter will have to wait until any of these 20 particles have died before it can regenerate a new particle. That is why we see the fire will get interrupted sometimes.
Smoke
This program generates some smoke effects:
Result
Explanation
- Color1 and Color2: dark colors are used with high transparency so that we can see through the smoke.
- Capacity: This emitter can emit up to 100 particles each second
- Texture Size: each particle is a 100-by-100 image like this:
-
Source Size: all particles are generated within a box region of size 20 around the origin
-
Speed: each particle will move at a speed of 30 units per second, since smoke usually travels very slowly
-
Max Life: each particle will die within 4 seconds randomly.
-
Firing Rate: up to 100 particles are emitted each second.
Light Spark
This program allows you to show a light spark for a very short time whenever the SPACE key is pressed:
Result
Note that no matter which way we rotate the camera, the spark is always facing the camera view.
Explanation
- Color1 and Color2: these are the starting and ending colors for each particle.
- Capacity: This emitter can only emit up to 3 particles each time since we don’t need many of them
- Texture Size: each particle is a 200-by-200 image like this:
-
Source Size: all particles are generated within a very small box of size 0.1 at the origin, so it looks like they all share the same origin
-
Speed: the particles will not be moving
-
Max Life: each particle will die within 0.2 seconds, so it will show up as a quick flash.
-
Firing Rate: the emitter will generate 3 particles together within a very short time. We have to start it again to get another spark.
Halo
This program produces an expanding circle facing the up direction at where we click:
Result
Explanation
- Color1 and Color2: these are the starting and ending colors for each particle.
- Capacity: This emitter can only emit up to 10 particles each time since we don’t need many of them
- Texture Size: each particle will start very small, and expand into a 300-by-300 image of this texture:
-
Source Size: all particles are generated within a very small box of size 0.1 at the origin, so it looks like they all share the same origin
-
Speed: the particles will not be moving, but they are expanding in size
-
Max Life: each particle will die within 0.2 seconds, so it will expand to its full size quickly and then disappear.
-
Firing Rate: the emitter will generate 1 particle each time. We have to start it again to get another halo.
In addition, we have turned on picking on the ground, so whenever a point is clicked, we move the emitter to that X and Y position and emit one particle there. We also set the Z position of the emitter to 1, so it will not overlap with the grass ground. The emitter has been rotated, so the circle will face up along the Z-axis.
Orb
This program produces a magic orb:
Result
Explanation
The “orb” emitter actually is composed of 4 children emitters: a light shooting out from the center, some smoke surrounding the light, many small light sparks, and a glowing circle.
-
Color1 and Color2: these are the range of colors for each particle.
-
Capacity: This emitter can only emit up to 100 particles
-
Texture Size: the size (diameter) of the orb
-
Source Size: all particles are generated within a very small box of size 0.1 at the origin, so it looks like they all share the same origin
-
Speed: the speed of the light sparks
-
Max Life: each light spark will die within 3 to 6 seconds
-
Firing Rate: the emitter will generate 30 spark particles every second.