Bullet not colliding with dying enemy

When an enemy is shot and is playing death animation id like it to still not go through walls but not collide with bullets. How would i do this?

The enemies have Rigidbody2D, are not kinematic and have Collider2D that are not triggers. The bullet (fireball) has a Rigidbody2D and a collider which is trigger.

The Unity doc has some good examples. Changing layers via script is also covered. Example:
Once enemy is dying change it’s layer to someLayer
On the bullet script, add a variable like

public LayerMask bulletLayers;

That will add a dropdown in your Editor, place checks next to the layers you want it to interact with, don’t check the layer marked someLayer.