How do I destroy a game object my character hit ONLY if a condition is active?

I need to do two things.

  1. have a pickup object that triggers a particle system on my character for x amount of time.

  2. have certain game objects able to be destroyed ONLY IF that particle system is active on my character
    otherwise the character dies when colliding with that same object.

For the pickup object:
• Make it a trigger
• Code:

public void OnTriggerEnter(Collider col) {
    if(col.gameObject.name == "Character")
       /* I don't know much about the light system so */
       // do light magic here
       lightMagic = true ; // have a boolean to know when the character is lit.
}

For the other part :

void OnCollisionEnter(Collider col) {
    if(col.gameObejct.name == " Character")
        if(lightMagic)
           Destroy(col.gameObject) ;  
         else Destroy(character) ;
}

So, I used a bit of what you recommended and a bit of stuff I just experimented with. Sharing for others.

This script is attached to my Player. I made my particle system attachable to the script via public ParticleSystem. On trigger, the pickup item is destroyed AND the particle system is played for 5 seconds (by unchecking “Looping” under particle system Inspector window and setting duration to 5 seconds)

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class FirePickup : MonoBehaviour {
	
	public ParticleSystem FirePickUp;

		void OnTriggerEnter(Collider other) 
		{
			if (other.gameObject.CompareTag ("Pick Up Fire"))
			{
				other.gameObject.SetActive (false);
				
				FirePickUp.Play ();
			}
		}
}

Next, also attached to the Player, this script destroys the “IceBarrier” object when Player collides on Trigger.

public class IceBarrierDestroy : MonoBehaviour
{
	void OnTriggerEnter(Collider other) 
	{
		if (other.gameObject.CompareTag ("BarrierIce"))
		{
			other.gameObject.SetActive (false);
		}
	}
}

The only remaining objective for this thread is, when Player collides with the object, the object (Icebarrier) is only destroyed IF the particle system (FlamePickUp) is active (5 sec duration remember) or ELSE Player is destroyed (by still active IceBarrier)