*Temporarily* turn off collision between player and enemy

I’m trying to get into Unity’s 2D development, so I downloaded the sample game project. The one with the bazooka and the London Bridge. One thing that really bugged me, the very first thing I wanted to change just to make the game PLAYABLE, is to make it so that the player can walk through enemies during “Mercy Invincibility”. That is, the period of time after taking damage during which the player cannot take more damage. The way the game is currently set up, collision between player and enemy is always active and they always collide, but the player will simply not take damage under certain circumstances.

How would I set it up such that collision between player and enemy is disabled during a certain period of time, then automatically re-enabled afterward? Do I want to mess with Physics2DSettings menu? Do I want to call the Physics.IgnoreCollision() function? Do I want to add new variables to the player’s global variables (like “public bool isTangible”)? Am I overlooking something simpler?

hello, you can access the collider of the object using GetComponent() and set the enabled property to false. you can use a coroutine for that.