Having a door open/disappear when collided with a specific particle...

For those who do not know, I am working on a game that involves the character changing his state (fire, water, air, etc…) via standing on a trigger. He then has the power to shoot fire/water/air/other when in the specific mode. I have that basic functionality in place. Now, however, I was looking forward to something more advanced - Involving the player having to shoot a fireball at a door in order for it to open, and it would not work with other powers. I have tried collision and triggers, but have failed miserably, and consulted this helpful community instead.

If any of you can guide me/help me out with the script, I would greatly appreciate it. Preferably I would like it in C#.

It depends on how you’re implementing the fireball. A simple “fireball recipe”: create an empty object (“Fireball”) and add to it a sphere collider, the particle effect, an AudioSource and a kinematic rigidbody (set Is Kinematic in the Inspector), then set the collider’s Is Trigger field in the Inspector to make it a trigger. Tag this object as “Fireball” and add the script below to it:

using UnityEngine;
using System.Collections;
 
public class Fireball: MonoBehaviour {

    public float speed = 8.0f;
    public AudioClip hitSound; // add a hit sound, if desired

    void Start(){
        Destroy(gameObject, 6); // suicide in 6 seconds
    }

    void Update(){
        // move the fireball forward at speed units/second
        transform.Translate(0, 0, speed * Time.deltaTime);
    }

    void OnTriggerEnter(){ // hit something:
        // play the hit sound, if any...
        if (hitSound) AudioSource.PlayClipAtPoint(hitSound, transform.position);
        Destroy(other.gameObject); // and die
    }
}

If you set the AudioSource Clip property to some sound, the fireball will play it when instantiated (Play On Awake is set by default). You can also add a hit sound to the field Hit Sound in the Inspector.

Finally, drag this object to the Project view to make it a prefab.

Now, the door: add a script like below to the door prefab, so that it will destroy itself when some trigger tagged “Fireball” hits it:

using UnityEngine;
using System.Collections;
 
public class FireballDoor: MonoBehaviour {

    void OnTriggerEnter(Collider other){
        if (other.tag == "Fireball"){
            Destroy(gameObject);
        }
    }
}

You may of course elaborate the OnTriggerEnter function so that it makes more interesting things when hit - like sinking in the ground with a convenient sound, for instance:

...
public class FireballDoor: MonoBehaviour {

    public float speed = 2.5f; // sinking speed in units/second
    public float doorHeight = 1.8f; // the door height

    IEnumerator OnTriggerEnter(Collider other){ // this is a coroutine now!
        if (other.tag == "Fireball"){ // if hit by a fireball...
            float endY = transform.position.y - doorHeight;
            if (audio) audio.Play(); // if some audio effect, play it
            while (transform.position.y > endY){ // repeat until door completely sunk 
                transform.position -= new Vector3(0, speed * Time.deltaTime, 0);
                yield return null;
            }
        }
    }

You should add an AudioSource to the door, and set its Clip property to some suitable audio clip in order to have a nice “sinking” sound.