Skip to content

Tutorials · Particle Effects · Chapter 10

Forces

20 minutes Uses: ParticleEmitter, ParticleAttractor

By the end

  • lamp_pull, an attractor that draws the fireflies to the second street lamp: Radius 44, Strength 110
  • well_swirl, turning the well’s ring, and fountain_head, fanning the fountain’s jet
  • Kind, Radius, Strength and Enabled, and why a pull that moves every particle in reach has to be a short one
On this page

A pull

Until now every particle has been moved by numbers on its own emitter: its Speed, its Gravity, its Drag. A Particle Attractor is a node that moves other emitters’ particles. It makes none of its own. It sits somewhere in the room and, every step, pulls on whatever particle is near it.

The fireflies you made in chapter 8 are born in a small circle 104 units to the right of the second street lamp, aimed to the left. An attractor over the lamp will draw them in as they pass.

  1. Select Town, press + Add node, and choose Particle Attractor. Rename it lamp_pull.
  2. Set its Position to 424 and 232, a little above the second street lamp.
  3. Set Radius to 44 and Strength to 110. Kind stays on Attract and Enabled stays ticked, as a new Particle Attractor has them.
  4. Press Ctrl+S, and then F5. Look at the fireflies near the lamp, and press F5 again to stop.

In the Viewport every attractor is an orange circle, its Radius, with a small arrow on its rim that shows which way it pushes, selected or not; the picture below also holds the well’s and the fountain’s, which come later in this chapter. A selected attractor’s circle is brighter, and it shows its name above the node and, on the circle at the right of the node, a small blue square. Drag the square and the Radius follows. The Move tool’s red arrow can lie over the square; press Q for the Select tool and it stands clear.

lamp_pull selected, its Inspector narrowed with the search box, particleattractor, to the Particle Attractor: Kind Attract, Radius 44.00, Strength 110.00 and Enabled ticked, with the search box counting 4 of 16 rows; the Select tool lit on the toolbar; in the Viewport a small white cross on the node above the second street lamp, its name beside it, inside a bright orange circle with a small arrow on its rim pointing in at the node, and a small blue square on the circle to the right of the node, the Radius handle; two fainter orange circles show the other two attractors, a small one over the fountain and one round the well
The lamp’s pull, as this chapter makes it. The small blue square is its Radius handle.
Kind
What the attractor does to a particle in reach. Attract pulls it toward the node, Repel pushes it away from the node, and Swirl pushes it sideways, round the node, clockwise as you look at the screen. The lamp is an Attract, the well’s is a Swirl, and the fountain’s is a Repel.
Radius
How far the attractor reaches from its node, in world units. A particle outside it feels nothing. 22 to 60 suits the small pulls in this town, and 44 is what you set. A new attractor starts at 96. Drag the blue handle in the Viewport to change it.
Strength
How hard it acts at the node, as an acceleration: world units a second, every second, the same unit as Gravity. It falls evenly to nothing at the Radius, so a particle halfway out feels half of it. 60 to 200 suits a draw on fireflies here, and 110 is what you set. A new attractor starts at 400.
Enabled
Whether the attractor acts now. Unticked, or with its node hidden, it does nothing. A script can switch it with set_flag, as chapter 13 switches an emitter’s Emitting on and off.
Close up of the second street lamp and the well at ten seconds, with the pull switched off: the lamp’s post and head stand in front of the brick wall with one firefly low beside the post, and the fireflies hang to the right of it, over the trees and the well’s roof, with a few higher over the left-hand houses
For comparison, the pull switched off: the fireflies hang over the well and the trees, and the lamp has hardly any.
The same close up with the pull on, **Strength** 110: seven or eight fireflies gathered in a loose knot over and round the lamp’s head, in front of the brick wall, where there was one before; the group over the trees and the well is as before
Ten seconds in, Strength 110: a knot of fireflies drawn in to the lamp.
The same close up at Strength 200: about as many fireflies at the lamp, sitting lower on the lamp’s head and nearer the post than at 110
For comparison, Strength 200: the knot sits a little lower, nearer the lamp’s head.

Whose particles it pulls

An attractor has no list of emitters. It pulls every particle inside its Radius, whichever emitter made it: the chimneys’ smoke, the fog, the rain, the fireflies. So the Radius is the only way to say whose particles a pull is for. Make it wide and it is for everyone.

The roofs, the second street lamp and the well at ten seconds with the lamp’s pull at Radius 230: the second chimney’s smoke leaves the chimney sideways and runs right across the roofs in a row of puffs toward the lamp, and the fireflies are packed in a knot over the lamp instead of spread across the trees
For comparison, Radius 230: the second chimney’s smoke is dragged across the roofs toward the lamp, and the fireflies are packed on it.
The same part of the town at Radius 44, as you set it: the second chimney’s smoke rises straight up out of its chimney and the fireflies are spread over the trees and the well, with a few at the lamp
Radius 44: the smoke rises as it did, and only the fireflies that come near the lamp are pulled.

A swirl and a push

The other two Kinds need a little more. A Swirl pushes a particle at a right angle to the line from the node to it, so a particle in reach goes round the node. A Repel pushes it straight out, away from the node. Both go on nodes of their own, as the pull did.

  1. Select Town, press + Add node, and choose Particle Attractor. Rename it well_swirl, and set its Position to 528 and 262, the well’s mouth. Set Kind to Swirl, Radius to 40 and Strength to 160.
  2. Select well_ring and set its Drag to 2.
  3. Add another Particle Attractor. Rename it fountain_head, and set its Position to 320 and 236, just above the fountain’s spout. Set Kind to Repel, Radius to 22 and Strength to 600.
  4. Press Ctrl+S, and then F5. Look at the well and the fountain, and press F5 again to stop.
well_swirl selected, its Inspector narrowed with the search box, particleattractor, to the Particle Attractor: Kind Swirl, Radius 40.00, Strength 160.00 and Enabled ticked, again 4 of 16 rows; the Select tool lit; in the Viewport a white cross on the well’s mouth with the name well_swirl beside it, inside a bright orange circle with a small arrow on its rim pointing down, round the rim, and a small blue square on the circle to the right of the cross, the Radius handle; two fainter orange circles show the lamp’s pull and the fountain’s push
The well’s swirl: Swirl, 40, 160.
Close up of the well at two seconds with the swirl switched off: the ring’s blue-white sparks are a loose cluster rising from the well’s mouth to just under its roof
For comparison, no swirl: the ring’s sparks drift up out of the mouth.
The same close up with the swirl on: the sparks are spread across the whole width of the well’s mouth, under the roof, in a wider, rounder ring
Swirl, 160: the sparks are spread round the well’s mouth in a ring, and keep circling it.
The same close up with the swirl on but the ring’s Drag at 0: the sparks are scattered, some out past the right of the well’s roof and some above it, a thin spray instead of a ring
For comparison, the ring’s Drag at 0: the swirl flings the sparks out of its reach.
Close up of the fountain’s jet at two seconds with the push switched off: a narrow stem of pale dots rises from the spout in front of the middle house and opens at its top into a short, tight spray
For comparison, no push: the jet rises as one stem and falls back as one arc.
The same close up with the push on: the stem is still narrow at the spout, but above it the dots are thrown wide to both sides, over the windows of the houses either side, a thin fan instead of a stem
Repel, 600: the jet is thrown wide where it passes the head.

The head sits 22 units above the spout, in the jet’s own way. A particle that rises into its circle is pushed out of the middle, to whichever side it was on, so the stem opens into a fan.

What a pull costs

The three attractors

The lamp’s pullValue
Position424, 232
KindAttract
Radius44
Strength110
Enabledticked
The well’s swirlValue
Position528, 262
KindSwirl
Radius40
Strength160
Enabledticked
The fountain’s headValue
Position320, 236
KindRepel
Radius22
Strength600
Enabledticked
The well’s ringValue
Position528, 262
Rate36
Speed4
Spread7
Gravity-8
Start Color0.55, 0.9, 1, alpha 1
End Color0.3, 0.5, 1, alpha 0
Start Size7
End Size3
Capacity48
Sort Layer4
BlendAdd
Texturesoft-dot.png
Drag2
ShapeCircle, Radius 12, Edge Only ticked

The ring’s Drag of 2 is the one value this chapter adds to it. The fireflies keep chapter 8’s values: the lamp moves them, and nothing on their own node changes.

Check it works