Collider behavior on object destruction

If two objects’ respective collision volumes are touching when one object is destroyed, will OnCollisionExit()/OnTriggerExit() (depending on the collider) be called on the remaining object? The situation I’m working on is a pipe game (similar to the old “Pipe Dreams” game or the hacking minigame in Bioshock), and if a pipe is removed from the board, I’m expecting that the following is called on the remaining objects that touch its endpoints (when a GameObject enters the collision volume, it is pushed onto connectedPipes.
):

var connectedPipes = new Array();
//...
function OnTriggerExit(other : Collider) {
    var exitingPipe = other.gameObject;
    if (exitingPipe.tag == "Pipe") {
        for (var i = 0; i < connectedPipes.length; i++) {
            if (connectedPipes[i] == exitingPipe) {
                connectedPipes.splice(i, 1);
                return;
            }
        }
    }
}

To see if the puzzle is solved, each pipe on the board checks to see if it either touches the finish or touches a pipe that does:

var touchesFinish = false;
//...

function Update() {
    touchesFinish = SearchForFinish();
}
//...

function SearchForFinish() {
    for (var pipe : GameObject in connectedPipes) {
        if (pipe) {
            if (pipe.name == "Finish" || pipe.GetComponent(PipeScript).touchesFinish == true) {
                return true;
            }
        }
    }
    return false;
}

But Unity reports the following:

The line it points to is “if (pipe)”, which is, if I understood the docs correctly, the way to check if an object is null.

So I suppose I have two questions:

  1. what should I be doing in this situation to avoid the missing reference exceptions?
  2. is there a more elegant way to handle business surrounding object destruction? AFAIK, there isn’t an OnDestroy() method in which I could tell the object to remove itself from these arrays before it’s destroyed.

erm very new to this but I’m pretty sure you need to have a manger. An array of all objects that you can add/delete a bit like the code below…

private var allUnitsList = new Array();
private var selectedUnitsList = new Array();

function GetSelectedUnitsCount() {
return selectedUnitsList.length;
}

function AddUnit(go : GameObject) {
allUnitsList.Add(go);
//print("UnitManager: added unit: " + go.name);
}

function DeleteUnit(go : GameObject) {
allUnitsList.Remove(go);
print("UnitManager: removed unit: " + go.name);
Destroy(go);
}

function AddSelectedUnit(go : GameObject) {
selectedUnitsList.Push(go);
go.SendMessage(“SetUnitSelected”, true);
print("UnitManager: added selected unit: " + go.name);

}

Sorry if this does not help!

My problem is:

If two objects are connected, and I destroy one of them, the other object does not get a OntriggerExit() sent… does it?

OntriggerStay is just far too slow for me… the CPU slows right down…

Help!