Unable to implement ignore collision

I am trying to ignore collisions between 2 objects in my 2D game without success. I have read the documentation of Physics2d.IgnoreCollision but I just cannot make it work. Both objects are prefabs and both have the collider componet. Do they need to be rigid bodies? I will appreciate any clue and/or code example a bit more explicit than documentation.

Best regards.

Most people can’t get collisions to work, rather than vice-versa. Let’s run through some possibilities.

  1. Persistence. You need to call IgnoreCollision before the collision occurs, but after the colliders are active. Furthermore, if either object becomes inactive, you will have to call it again if it’s reactivated.
  2. Multiple colliders. Are there additional colliders on the objects? IgnoreCollision only does one set for each call.
  3. Clones. You mentioned these are Prefabs. I don’t think the IgnoreCollision status will carry to instantiated clones - you’d have to call it again.

Not sure if you will always be avoiding collisions with these certain objects but if you intend to, you can assign them to Layers.
Then, go to: Edit > Project Settings > Physics > Layer Collision Matrix
Then uncheck where the two (or more) types you’d like to avoid collisions with one another meet.

or you could make an if statement, if the collider comes into contact with the other, you could temporarily disable it until the if statement becomes false again?