Each effect is a ScriptableObject you create from the Assets, Create menu (Physics, Effects for 3D and Physics, 2D Effects for 2D) and list on a Force Effect Field or Direction. The strength a field passes in means something different for each effect, so read the strength line first.
Most effects have two switches, EffectLinear for pushing and EffectTorque for turning. A body only gets the parts that are on in both the effect and its ForceEffectReceiver (useLinear, useAngular). GravityEffect has no torque part. Wind has linear and torque in 3D, and linear only in 2D.
| Effect | Strength means | Behaviour |
|---|---|---|
| Attract | A force, in the chosen ForceMode | Pulls toward a point source or along a directional source’s direction. With EffectTorque it turns the body to face the source. |
| Repulse | A force, in the chosen ForceMode | Pushes away from a point source or against a direction. With EffectTorque it turns the body to face away. |
| Tractor | A speed in metres per second | Steers the body to that speed toward the source, slowing as it arrives, so it holds a steady speed and does not overshoot. |
| Gravity | An acceleration in metres per second squared | A gravity well. Pulls toward the source and cancels world gravity on the body while it is inside. |
| Suspend | A rate in 1 per second | Brings the body to a stop, as if held in a thick medium. At 1, about two thirds of the speed is gone after a second. |
| Wind | A multiplier on the wind’s force | Gusting, swirling wind that applies real drag to the body. |
Attract and Repulse #
The simplest effects. Choose the mode (a Unity ForceMode, or ForceMode2D in 2D) and the strength is applied as a force in that mode along the direction toward (Attract) or away from (Repulse) the source. Use them for magnets, explosions and shockwaves.
| Setting | What it does |
|---|---|
mode | How the force is applied (Force, Acceleration, Impulse or VelocityChange). |
EffectLinear | Push or pull the body. |
EffectTorque | Turn the body to face the source (Attract) or away from it (Repulse). In 2D the body’s right side faces the source. |
Tractor #
A tractor beam. The strength is a speed in metres per second, and the body is steered to that velocity toward the source instead of being pushed, so it does not overshoot. Near a point source the speed falls away inside arrivalDistance so the body slows to a stop at the source.
| Setting | Default | What it does |
|---|---|---|
EffectLinear | off | Draw the body toward the source. |
EffectTorque | off | Turn the body to face the source, blended by the strength up to 1. |
maxAcceleration | 0 | The most acceleration in metres per second squared the beam may apply. Zero for no limit. |
arrivalDistance | 1 | The distance from a point source inside which the body slows to a stop. |
Gravity #
A gravity well. The strength is an acceleration in metres per second squared toward the source. While a body is in the field its own world gravity is cancelled by counter acceleration, nothing on the Rigidbody is changed, so it falls normally again the moment it leaves. Build planets, black holes or low-gravity zones by combining it with a field and a matching radius or constant curve.
| Setting | Default | What it does |
|---|---|---|
disableBodyGravity | on | Cancel the world gravity on the body while it is in the field. |
Suspend #
Holds a body as if in a thick medium. The strength is how fast motion dies away, in 1 per second, applied as an acceleration so it does not depend on the physics time step.
| Setting | Default | What it does |
|---|---|---|
EffectLinear | off | Slow the movement of the body. |
EffectTorque | off | Slow the rotation of the body. |
Wind #
Wind blows away from a point field, or along a directional field. The force is the real drag of the wind on the body: 0.5 x air density x drag coefficient x area x relative speed squared, where the speed is the wind relative to the body, so a body carried along at the wind speed feels nothing. The area is the shadow of the body along the wind, taken from its PhysicsData, or fallbackCrossSection when the body has none. The torque comes from the same force acting at the body’s centre of volume rather than its centre of mass, so a body with a large sail area turns to catch the wind.
| Setting | Default | What it does |
|---|---|---|
EffectLinear | off (on in 2D) | Push the body. |
EffectTorque | off | Apply the torque of the wind acting off the centre of mass. Needs a PhysicsData on the body. 3D only. |
volumetricDensity | 1.239 | The density of the air in kg per cubic metre, around 1.2 at sea level. |
dragCoefficient | 1 | Around 1 for a blunt object and 0.5 for a rounded one. |
fallbackCrossSection | 1 | The cross section in square metres used for a body with no PhysicsData. In 2D this is crossSection, the width the wind meets in metres. |
metersPerSecond | 8 | The steady wind speed at full strength. |
frequency | 0.3 | How often the wind gusts, in cycles per second. |
magnitude | 1.5 | How much the speed swings each way during a gust, in metres per second. |
turbulence | 0.15 | How quickly the wind direction wanders, within 30 degrees either side. Zero for a constant direction, around 0.1 to 0.3 for a breeze, higher is gusty and erratic. 3D only. |
WindEffect.Force(source, strength, subject, data) returns the force in newtons for a body, and is public so you can use the same calculation in your own code.
2D differences #
- 2D effects derive from
ForceEffect2Dand act onRigidbody2D. They are created from Assets, Create, Physics, 2D Effects. ForceEffectDirection2Dacts along its right (X) axis because forward has no 2D component.WindEffect2Dhas no torque and no turbulence, and usescrossSectioninstead of a hull.- Attract2D and Repulse2D use
ForceMode2D. TorqueToReachDirection2Dworks in radians even thoughRigidbody2D.angularVelocityis in degrees per second, see Physics Maths.