Particles: change single particle color

Hi guys,
I’ve a question.
Consider an object moving on a surface that has different colors.
This object emits particles.
I’d like to color the emitted particles according to the colors of the surface where the object move over.

I’ve tried to change the start color of a particles system but it changes all the emitted particles.

Is there a way to change the color of the new single emitted particles keeping the color of the old ones?

Thanks in advance.

Afaik changing the start color should be fine. If you’re testing this in the editor, make sure to disable the Resimulate option.

2 Likes
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class ParticleStartColorTest : MonoBehaviour {

    ParticleSystem ps;
    Vector3 pos;

    void Start () {
        ps = GetComponent<ParticleSystem>();
        pos = transform.position;
    }
  
    void Update () {
        if (ps == null)
        {
            enabled = false;
            return;
        }

        Vector3 newPos = pos;
        newPos.x = Mathf.Sin(Time.timeSinceLevelLoad) * 3f;
        transform.position = newPos;

        var main = ps.main;
        main.startColor = Random.ColorHSV(0f, 1f, 0f, 1f, 0.5f, 1f, 1f, 1f);
    }
}

4757228--451829--upload_2019-7-17_10-7-37.png

2 Likes