How to Ignore Only The First Collision Between Two Objects?

Hello!
So I’m trying to make a 2D game in which a player releases a projectile, which is instantiated inside of the player itself. In order to avoid unwanted collisions between the player and the created projectile, I disabled collisions between their layers in the Physics2D project settings. However, I want to edit this so that the projectile can collide with the player later on (Let’s say, if the projectile ricochets back at the player).

Essentially, I’m asking how to edit my game so that the FIRST collision between the player and the projectile(When the projectile is first spawned inside the player) is ignored, yet the object will collide and interact with my player any time afterwards.

Hi,

With game settings, i don’t think that’s possible … so i’d script it:

void OnTriggerEnter () {
   if(!firstCollisionOccured){
      firstCollisionOccured = true;
   } else {
      // normal stuff
   }
}

i wouldn’t touch the collision layers in this case but use a bool variable that will hold the state of the projectile:

false = can’t damage player

true = can damage player

then use the OnCollisionExit2D on the projectile to change the variable state. once the projectile leave the player area the variable change state. and then, when the projectile hit the player again check this var again to make sure it can damage the player.