How do I get a prefab to ignore collisions with a different prefab?

I am currently working on a platformer game that involves a death animation once the player has run out of health. I am wanting the player to be able to ignore 2d collisions with an enemy, as it is going through the animation. I have already tried using the code: Physics2D.IgnoreCollision(Player.GetComponent(), Enemy.GetComponent());

But this only works for a single enemy not all of them. I have attached the enemy prefab to the player under a game object, but still no luck.

Appreciate the Help

Maybe use Physics2D.IgnoreCollision() in your enemy instead, if there’s only one player. Then it’ll be on every enemy prefab and they will ignore the collisions instead of the player trying to ignore them all.