Check Color of colliding particle?

I want to make a top down space shooter.
The bullets are particle.

On my Enemy Class i have made this:

    void OnParticleCollision(GameObject other) {
            life--;
            if (life <= 0) {
                Destroy(gameObject);
            }
        }

This working perfect.
But one of my mechanic in this game is, to shoot bullets with different color.
So the player can switch his bullet color.

Some Enemys are resisdent against a specific color.
So I must check in the OnParticleCollision() which color the colliding Particle have.

void OnParticleCollision(GameObject other) {
        life--;
        //Check here which Color this Particle have
        //<--- insert code
        if (life <= 0) {
            Destroy(gameObject);
        }
    }

Does somebody has any idea?

void OnParticleCollision(GameObject other)
{
life–;
//Check here which Color this Particle have
if (other.GetComponent().material.color == /* color here */)
{

        }
        if (life <= 0)
        {
            Destroy(gameObject);
        }
    }

You will then input the color of the particle that you want detected. You would input something like Color.red, but make sure that if you do that, that the color that you have the particle is exactly the color you input, like Color.red, the particle color needs to be R: 255, B: 0 G: 0.
I have not tried this yet, but it should work :slight_smile: