Moving and Rotating Particles
-
Prerequisite
Introduction
Suppose you already know how to create a single-point particle emitter, you can also make the particles move and rotate, which will create more interesting patterns.
Movement Speed and Direction
You can set the moving speed and direction of the particles using the following block:
The first parameter is the name of the emitter you want to update, which can be left empty if the emitter is the currently selected sprite object.
The next 2 parameters set the minimum and maximum speed of the particles. For each particle, it will pick a random speed within this range. By default, the speed is 0 for all particles.
The next 6 parameters allow us to set 2 directions. For each direction, you can specify 3 numbers as X/Y/Z positions. You can think of it as an arrow shooting from the origin of the world to a point at the given X/Y/Z positions. For example, if you want the particle to move up along the Z axis, you can set x to 0, y to 0 and z as 1. If you want the particle to move to the right, you can set x to 1, y to 0 and z to 0.
If direction 1 and direction 2 are different, then each particle will pick a random direction in-between these 2 directions.
Example 1 - Rising Particles
In this program, we set the min and max speeds to 100, so every particle is at the same speed. Direction 1 and direction 2 are the same. They are both pointing upwards. The capacity and emitting rate are both 5, so we see 5 circles going up continuously.
Example 2 - Different Speeds
Suppose we change the minimum speed to 10, then the 5 particles may have a random speed between 10 and 100.
We see some moving faster and some slower, so the faster ones may rise through the slower ones:
Example 3 - Different Directions
In this example, we increase the capacity to 30, set speed to 100 for all particles, then change direction 2 to point to the right.
As a result, the particles will randomly move in the up right direction:
Rotation Speed
We can also make each particle rotate around its own center. Recall that each particle is just a 2D image, so it can rotate just like how any image rotates around itself. This block is used to set the rotation speed:
The first parameter is the name of the emitter you want to update, which can be left empty if the emitter is the currently selected sprite object.
The next 2 parameters set the minimum and maximum rotation speed of the particles at the very beginning. The number is given in degrees, so a value of 360 means the particle image would make a full rotation each second. For each particle, its rotation speed will be randomly picked between these 2 numbers.
After that, you can also specify the ending rotation speed. You can make the particles rotate faster toward the end by setting some larger values for the ending rotation speed.
Lastly, you can specify the rotation speed at an intermedia point. For example, if the “progress point” is 50%, then the particle’s rotation speed will be set to a random value between the last 2 inputs when it is exactly halfway through its lifetime.
Example 4 - Rotating at Fixed Speed
In this example, we have only one particle in the system, which grows from size 1 to size 100 by default. We set its rotation speed to be fixed at 360 degrees per second.
Example 5 - Rotating at Increasing Speed
In this example, we set the starting rotation speed to 0, and ending speed to 720 degrees per second. For the 10 particles, we can see that they do not rotate much when the are just created, then they start to rotate faster and faster as they grow bigger.
Example 6 - Rotating and Moving
In this example, we make the particles rise up and rotate and the same time. The rotation speed also increases over time. They form a “tornado” pattern.
-