I’m making a shooter. I have a player ship firing bullets at enemies and destroying them when their health reaches 0. Most of the time this works great. The enemies and the bullets are pooled.
Sometimes an enemy will spawn and when bullets are fired at it OnTriggerEnter2D is never called. Their components appear to be set up the right way, IsTrigger is set to true, etc.
The OnTriggerEnter2D calls for every other object work fine. I’m not sure where to go from here.
//enemy trigger code
void OnTriggerEnter2D( Collider2D collider)
{
if (collider !=null && collider.gameObject != null && collider.gameObject.tag.Equals("PlayerBullet"))
{
hitSignal.Dispatch();
if (health <= 0)
{
destroyedSignal.Dispatch();
}
}
}