Class SurfaceParticleSystem
Controls particle emission for a single wheel, generating tire smoke and surface dust based on wheel behavior.
Namespace: NWH.VehiclePhysics2.Effects
Assembly: NWH.VehiclePhysics2.dll
Syntax
[Serializable]
public class SurfaceParticleSystem
Remarks
SurfaceParticleSystem manages two distinct particle effects per wheel:
Smoke Particles: Emitted during tire slippage (wheelspin, braking, drifting). Emission rate scales with slip magnitude - more slip produces more smoke. Suitable for asphalt, concrete, and other hard surfaces. The system monitors longitudinal slip (acceleration/braking) and lateral slip (cornering/drifting) separately, using whichever is greater.
Dust Particles: Emitted when rolling over loose surfaces like dirt or gravel. Emission is speed-based rather than slip-based, creating ambient dust as the wheel rolls. The binaryEmission flag controls whether dust appears gradually or instantly.
Chunk Particles: Small debris ejected by wheel rotation on loose surfaces. Emission and speed scale with wheel angular velocity and slip.
Particle properties (color, size, lifetime) come from the SurfacePreset assigned to the current ground surface. The system automatically switches between smoke and dust behavior based on the surface's particleType setting.
Fields
binaryEmission
When true, particles emit at full rate or not at all with no gradual transition. Use for dusty surfaces (gravel, sand) where slip magnitude doesn't affect dust amount. When false, emission smoothly interpolates with slip for surfaces like asphalt.
Declaration
[Tooltip(" Makes the particle either emit or not emit with no in-between.")]
public bool binaryEmission
Field Value
| Type | Description |
|---|---|
| bool |
chunkPS
Particle system for chunks kicked up by the wheel
Declaration
public ParticleSystem chunkPS
Field Value
| Type | Description |
|---|---|
| ParticleSystem |
chunkPrefab
Prefab for the chunks kicked up by the wheel.
Declaration
public GameObject chunkPrefab
Field Value
| Type | Description |
|---|---|
| GameObject |
emissionRateCoeff
Multiplier applied to the base emission rate from the SurfacePreset. Values above 1 produce more particles, below 1 produce fewer. Set by SurfaceParticleManager.
Declaration
[Tooltip(" Coefficient by which the emission rate will be multiplied.")]
public float emissionRateCoeff
Field Value
| Type | Description |
|---|---|
| float |
lateralSlipCoeff
Multiplier for lateral (sideways) slip contribution to smoke emission. Higher values produce more smoke during drifting and cornering. Only affects Smoke type particles. Set by SurfaceParticleManager.
Declaration
[Tooltip("Coefficient by which the lateral slip will be multiplied.\r\nIncrease the value to emit more particles when there is lateral slip (wheel skid / drift).")]
public float lateralSlipCoeff
Field Value
| Type | Description |
|---|---|
| float |
longitudinalSlipCoeff
Multiplier for longitudinal (forward/backward) slip contribution to smoke emission. Higher values produce more smoke during wheelspin and hard braking. Only affects Smoke type particles. Set by SurfaceParticleManager.
Declaration
[Tooltip("Coefficient by which the longitudinal slip will be multiplied.\r\nIncrease the value to emit more particles when there is longitudinal slip (wheel spin).")]
public float longitudinalSlipCoeff
Field Value
| Type | Description |
|---|---|
| float |
particlePS
Smoke particles particle system
Declaration
public ParticleSystem particlePS
Field Value
| Type | Description |
|---|---|
| ParticleSystem |
particlePrefab
Smoke particles prefab
Declaration
public GameObject particlePrefab
Field Value
| Type | Description |
|---|---|
| GameObject |
particleSizeCoeff
Multiplier applied to the base particle size from the SurfacePreset. Values above 1 create larger particles, below 1 create smaller ones. Set by SurfaceParticleManager.
Declaration
[Tooltip(" Coefficient by which the particle start size will be multiplied.")]
public float particleSizeCoeff
Field Value
| Type | Description |
|---|---|
| float |
surfacePreset
Surface preset for this SurfaceParticleSystem
Declaration
[SerializeField]
public SurfacePreset surfacePreset
Field Value
| Type | Description |
|---|---|
| SurfacePreset |
Methods
Destroy()
Stops coroutines and destroys the spawned particle and chunk GameObjects so re-init doesn't orphan them.
Declaration
public void Destroy()
Disable()
Stops the particle and chunk update coroutines and stops playing the particle systems.
Declaration
public void Disable()
Enable()
Starts the particle and chunk update coroutines and begins playing the particle systems.
Declaration
public void Enable()
Initialize(VehicleController, WheelComponent)
Initializes the particle system by instantiating particle and chunk prefabs as children of the wheel.
Declaration
public void Initialize(VehicleController vc, WheelComponent wheelComponent)
Parameters
| Type | Name | Description |
|---|---|---|
| VehicleController | vc | The parent vehicle controller. |
| WheelComponent | wheelComponent | The wheel this particle system is attached to. |