OnTriggerExit not triggered when object/trigger inside is destroyed c#

I am trying to do the following:
I’ve got an enemy with a sensor that stops walking when it enters a trigger of a destructible wall. It then starts to attack. When the wall’s health is 0 I want the enemy to start walking again. So far so good…on paper.

OnTriggerEnter makes the enemy stop walking, OnTriggerStay makes the enemy attack, OnTriggerExit should make the enemy start walking again.

The issue I am getting though is that the OnTriggerExit of enemy sensor is never triggered. When I “get rid” of the wall (by setting it to a layer that has no collision with the enemy or destroy it) the enemy stills says it is stuck in the wall trigger according to the debug.log. When I animate the wall to move the enemy will start moving again until it hits the wall’s new position. Moving it a gazillion units away from its current position, as suggested in other threads, doesn’t really seem like a nice sollution, right?

I am getting the feeling as if getting rid of the wall, while the enemy’s sensor is static, doesn’t properly trigger the OnTriggerExit as I’d expect.

Another similar issue occurs where I have a sentrygun shoot when an enemy enters its trigger. Everything works perfectly but as the enemy is destroyed in the trigger, the sentrygun never gets the OnTriggerExit which results in a sentrygun that keeps on firing as if there is no tomorrow.

Any ideas what I am missing here? I am using C# by the way. This is the script that is attached to the enemy sensor.

void OnTriggerEnter (Collider other)
		walk = false;
void OnTriggerStay (Collider other)
		if (other.gameObject.CompareTag("LevelDestructible"))
			other.gameObject.SendMessage("ChangeHealth", damage * Time.deltaTime, SendMessageOptions.DontRequireReceiver);
			Debug.Log("collide with destructible");
	void OnTriggerExit (Collider other)
			walk = true;

Why don’t you simply get a target with OnTriggerEnter of whatever type it is you have (like Wall) while the wall’s health is still greater than 0 or while you still have a target, continue to attack the target in an update loop. If you lose your target or your target’s health reaches a value, then stop attacking and continue movement.

I think you are misusing the OnTriggerStay method with what you are doing. A better example for how to use it would be the following.

You have a particular room filled with a substance that deals damage to your character. If your character enters (OnTriggerEnter) the collider associated with the substance, the player takes an initial amount of damange. Now, you can use OnTriggerStay to make the player take periodic damage while he remains in the substance/collider.