# colorBySpeed

> Script interface for the ColorByLifetimeModule of a Particle System.

## Definition

* **Type:** Property
* **Namespace:** [UnityEngine](/engine/6000.5/script-reference/unityengine.md)
* **Assembly:** UnityEngine.ParticleSystemModule

```csharp
public ParticleSystem.ColorBySpeedModule colorBySpeed { get; }
```

### Remarks

This module assigns colors to the particles based on the speed that they are travelling.

Particle System modules do not need to be reassigned back to the system; they are interfaces and not independent objects.

### Examples

```csharp
using UnityEngine;
using System.Collections;

[RequireComponent(typeof(ParticleSystem))]
public class ExampleClass : MonoBehaviour {
    void Start() {
        ParticleSystem ps = GetComponent<ParticleSystem>();
        var col = ps.colorBySpeed;
        col.enabled = true;

            Gradient grad = new Gradient();
            grad.SetKeys( new GradientColorKey[] { new GradientColorKey(Color.blue, 0.0f), new GradientColorKey(Color.red, 1.0f) }, new GradientAlphaKey[] { new GradientAlphaKey(1.0f, 0.0f), new GradientAlphaKey(0.0f, 1.0f) } );

            col.color = grad;
    }
}
```
