OnTriggerExit not working when object goes inactive

Hi,

I am using a pooling system and as a result enemies get despawned or set as inactive, my problem is that the enemy sets off the ontrigger enter and the good guy shoots at him, but when he dies(despawns) the good guy thinks he is still there and keeps shooting.

Wouldn’t being set as inactive trigger the ontriggerexit event on the good guy and make him stop shooting?

How can I accomplish this so he stops shooting?

Thanks.

Use OnDisable() on the enemy to tell the good guy to stop shooting

Collision and Trigger events are called when colliders with at least one rigidbody between them touch. The OnTriggerExit is called when they no longer touch. I can see that logically you would think that since the object has been disabled, it is no longer touching and should send the event. But if it’s disabled then how can it call the event?

yeah problem is that OnDisable() will cause good guy to stop firing, that will work…

but when there is another enemy there shooting, the good guy wont fire.

Ok so is there a way I can call the OnTriggerExit event ?