[C#] How to destroy a wall next to my trigger?

In my game I’d like for a wall to explode next to my character when he passes through an invisible box collision trigger next to the wall. I have a solid box prefab which spawns broken pieces that will be affected by gravity through a Rigidbody component.

My problem is that I can’t connect the trigger to the rest of the code. I admit I’m new to C# so I know I’m probably missing something, but I’ve been sitting here for about half an hour with little results. I’m building the code off of quill18create’s destructible walls tutorial.

TL;DR I need to create an invisible trigger which, when passed through, will replace my solid box with the destructible one.

Here’s what I have so far:

using UnityEngine;
using System.Collections;

public class Destructable : MonoBehaviour {
	
	public GameObject debrisPrefab;
	public Collider debrisTrigger; 
	
    void OnCollisionEnter (Collision col){
        if(col.gameObject.name == "collapseTrigger")
        {
            Destroy(col.gameObject);
		     DestroyMe();
        }
}
		
	void DestroyMe() 
	{
		if(debrisPrefab) 
		{
			Instantiate(debrisPrefab, transform.position, transform.rotation);
		}
		
		Destroy(gameObject);
    }
}

I would throw a Debug statement in that OnCollisionEnter to make sure that is being set off. OnTriggerEnter(Collider other) may be called instead so I would throw that in as well and see if that gets called. If that doesn’t work, you may also want to check the collision action matrix since some colliders will not interact with each other: Unity - Manual: Box Collider component reference (at the bottom of the page)

And make sure isTrigger is checked on your collider.

I think the issue is what you destroy, you seem to destroy the trigger but is the trigger the wall you want to go down?

Attach the trigger to the wall to destroy and put this below on the wall/trigger object:

using UnityEngine;
using System.Collections;
 
public class Destructable : MonoBehaviour {
 
public GameObject debrisPrefab;
 
void OnTriggerEnter (Collider col){
  if(col.gameObject.name == "collapseTrigger"){
    if(debrisPrefab){
      Instantiate(debrisPrefab, transform.position, transform.rotation);
    }
    Destroy(gameObject);
  }
}