Affecting Particles

Particles are emitted by the emitter. After a particle was emitted it can’t be changed any more by the emitter. The affectors allows you to influence particles after they have been emitted.

Each type of affector affects particles in a different way:

  • Age - alter where the particle is in its life-cycle
  • Attractor - attract particles towards a specific point
  • Friction - slows down movement proportional to the particle’s current velocity
  • Gravity - set’s an acceleration in an angle
  • Turbulence - fluid like forces based on a noise image
  • Wander - randomly vary the trajectory
  • GroupGoal - change the state of a group of a particle
  • SpriteGoal - change the state of a sprite particle

Age

Allows particle to age faster. the lifeLeft property specified how much life a particle should have left.

  1. Age {
  2. anchors.horizontalCenter: parent.horizontalCenter
  3. width: 240; height: 120
  4. system: particleSystem
  5. advancePosition: true
  6. lifeLeft: 1200
  7. once: true
  8. Tracer {}
  9. }

In the example, we shorten the life of the upper particles once when they reach the age of affector to 1200 msec. As we have set the advancePosition to true, we see the particle appearing again on a position when the particle has 1200 msecs left to live.

image

Attractor

The attractor attracts particles towards a specific point. The point is specified using pointX and pointY, which is relative to the attractor geometry. The strength specifies the force of attraction. In our example we let particles travel from left to right. The attractor is placed on the top and half of the particles travel through the attractor. Affector only affect particles while they are in their bounding box. This split allows us to see the normal stream and the affected stream simultaneous.

  1. Attractor {
  2. anchors.horizontalCenter: parent.horizontalCenter
  3. width: 160; height: 120
  4. system: particleSystem
  5. pointX: 0
  6. pointY: 0
  7. strength: 1.0
  8. Tracer {}
  9. }

It’s easy to see that the upper half of the particles are affected by the attracted to the top. The attraction point is set to top-left (0/0 point) of the attractor with a force of 1.0.

image

Friction

The friction affector slows down particles by a factor until a certain threshold is reached.

  1. Friction {
  2. anchors.horizontalCenter: parent.horizontalCenter
  3. width: 240; height: 120
  4. system: particleSystem
  5. factor : 0.8
  6. threshold: 25
  7. Tracer {}
  8. }

In the upper friction area, the particles are slowed down by a factor of 0.8 until the particle reaches 25 pixels per seconds velocity. The threshold act’s like a filter. Particles traveling above the threshold velocity are slowed down by the given factor.

image

Gravity

The gravity affector applies an acceleration In the example we stream the particles from the bottom to the top using an angle direction. The right side is unaffected, where on the left a gravity effect is applied. The gravity is angled to 90 degrees (bottom-direction) with a magnitude of 50.

  1. Gravity {
  2. width: 240; height: 240
  3. system: particleSystem
  4. magnitude: 50
  5. angle: 90
  6. Tracer {}
  7. }

Particles on the left side try to climb up, but the steady applied acceleration towards the bottom drags them into the direction of the gravity.

image

Turbulence

The turbulence affector applies a chaos map of force vectors to the particles. The chaos map is defined by a noise image, which can be defined with the noiseSource property. The strength defines how strong the vector will be applied to the particle movements.

  1. Turbulence {
  2. anchors.horizontalCenter: parent.horizontalCenter
  3. width: 240; height: 120
  4. system: particleSystem
  5. strength: 100
  6. Tracer {}
  7. }

In the upper area of the example, particles are influenced by the turbulence. Their movement is more erratic. The amount of erratic deviation from the original path is defined by the strength.

image

Wander

The wander manipulates the trajectory. With the property affectedParameter can be specified which parameter (velocity, position or acceleration) is affector by the wander. The pace property specifies the maximum of attribute changes per second. The yVariance and yVariance specify the influence on x and y component of the particle trajectory.

  1. Wander {
  2. anchors.horizontalCenter: parent.horizontalCenter
  3. width: 240; height: 120
  4. system: particleSystem
  5. affectedParameter: Wander.Position
  6. pace: 200
  7. yVariance: 240
  8. Tracer {}
  9. }

In the top wander affector particles are shuffled around by random trajectory changes. In this case, the position is changed 200 times per second in the y-direction.

image