Manual

Manual

Particle Force Field

A Particle Force Field is a shape in the scene that moves the particles inside it: a whirlpool for leaves, a magnet for sparks, wind through a doorway, a vortex round a portal. This page covers the field's shape and forces, the External Forces module that lets an emitter feel fields, and how fields work in 2D.

Make a force field

Entity ▸ Effects ▸ Particle Force Field, or the same item in the Hierarchy's + menu, makes one: a sphere of radius 1 about its entity, doing nothing until you give it a force. Add Component puts one on any entity.

A field moves only the particles of emitters that have the External Forces module on, and whose Influenced By names the field's layer. It moves nothing else.

The Scene view marks a field with a hurricane. While it is picked, it draws the outline of its End Range, and fainter that of its Start Range, in its entity's space and scale.

Particle Force Field

Its shape

FieldWhat it does
ShapeSphere: a ball about its middle. Hemisphere: the upper half of one, above its XZ plane. Cylinder: standing along its Y. Box: its End Range is its half size along each axis.
Start RangeHow far from its middle it begins to act. Nothing nearer is moved.
End RangeHow far from its middle it reaches: a sphere's radius, a cylinder's from its axis, a box's half size.
LengthCylinder: how long it is along its Y.

The shape is in its entity's space: moved, turned and scaled with it.

What it does

Each force is a number of any kind (a constant, a curve over each particle's life, or one picked between two), chosen with the ▾ at its row's right as an emitter's are; see Numbers that change: curves and gradients.

PartFieldWhat it does
DirectionX, Y, ZA push along the field's own axes, in units a second each second, turned with it: wind.
GravityStrengthA pull toward its middle, toward its axis in a cylinder, in units a second each second. Negative pushes away.
FocusWhere Gravity pulls toward, from 0, its middle, to 1, the surface its End Range makes, so particles settle on a shell.
RotationSpeedA swirl about the field's Y: how fast particles go round, in units a second. Negative goes the other way.
AttractionHow strongly particles are brought round at that speed: 0 not at all, 1 at once. It starts at 0.5.
RandomnessHow far each particle's axis is tilted its own way: 0 none, 1 a quarter turn.
DragStrengthHow much of their speed particles lose each second.
Multiply by SizeSlows bigger particles more, by their size. On to begin with.
Multiply by VelocitySlows faster particles more, by their speed. On to begin with.

Fields act in the world's space, whatever an emitter's Simulation Space is. Where fields overlap, a particle feels each of them.

External Forces

An emitter feels force fields through its External Forces module. Tick its heading in the emitter's Inspector to put it on.

FieldWhat it does
MultiplierWhat each field's push, pull, swirl and drag are multiplied by. It starts at 1.
Influenced ByWhich layers' fields move this emitter's particles. Every layer, to begin with.

A field is on its entity's layer, set in the Inspector's header; see Layers. Putting fields on layers of their own lets one emitter feel the wind while another does not.

An emitter without the module looks for no fields and pays nothing for them. A field costs nothing a frame of its own: each emitter with the module tests its particles against the fields as it moves them.

In 2D

A flat emitter's particles are moved in their plane. A field acts on them where its shape crosses that plane, its pushes along Z are ignored, and its Rotation swirls about Z, the axis a 2D camera looks along.

From code

A Particle Force Field is a component of the engine's, and its settings are fields like any other component's. From C#, its plain number and tick fields, such as end_range or gravity_focus, are reached through its layout, as any engine component written in Rust is (see How C# sees a Rust component):

ComponentLayout field = schedule.World.LayoutOf("ParticleForceField");ComponentField reach = field["end_range"];
schedule.Add("Pulse fields", [field.Write()], context =>{    foreach (Chunk chunk in context.Chunks)    {        FieldView<float> ranges = chunk.GetFieldView<float>(0, reach);        for (int row = 0; row < ranges.Length; row++)        {            ranges[row] = 2f + MathF.Sin(context.Frame * 0.05f);        }    }});

In the Scripting API