Need help to Ignore Collision between two gameobjects

Hello! So I am trying to make so a character which you can move and all of that basic stuff doesn’t collide with the shots the character can shoot. Right now I am trying to use the “tag” system to prevent the collision. But can’t get it to work:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerCollision : MonoBehaviour
{

public GameObject bulletPrefab;

void OnCollisionEnter(Collision collision)
{
    if (collision.gameObject.tag == "Bullet")
    {
        GameObject bullet = Instantiate(bulletPrefab);
        Physics.IgnoreCollision(bullet.GetComponent<Collider>(), GetComponent<Collider>());
        Debug.Log("This should not appear!");
    }

}

}

I did reference the bulletprefab in the inspector as well. Does it have to do with the bullet spawning in when I shoot? Since it’s not in the scene until I press the fire button.

(I do see the Debug.Log text in the console to point that out!)

(The character is a sprite with a box collider attached to it! And both the bullet and the player has a collider and a rigidbody!)

Thanks in advance for you who can help me with this! Have a nice day!

Best Regards

Put your bullet in a differnt layer. Then go Edit>Project Settings>Physics. Then deactivate checkbox that referances to bullets layer and your players layer.