Physics.IgnoreCollision both colliders need to be activated when calling this ignorecollision

I’m trying to make a projectile (Prefab) shoot out of a car (Prefab) and be able to detect collisions with other objects, mostly other cars. For the hooks themselves I have the Prefab on layer 10 and do a Physics.IgnoreLayerCollision so the hooks will ignore their own collisions, this works fine as far as I can tell. However when I instantiate the hook it won’t ignore the collision with the car that spawned it. Here I try to do this:

Transform createdProjectile = (Transform)Instantiate(HookTemplate, transform.position + directionVector, transform.rotation);
Debug.Log("CarAll collider: " + collider.enabled);
Debug.Log("createdProjectile collider: " + createdProjectile.collider.enabled);
Physics.IgnoreCollision(collider, createdProjectile.collider);

But when I drive my car into the hook it collides and gives an error:

Ignore collision failed. Both colliders need to be activated when calling this IgnoreCollision UnityEngine.Physics:IgnoreCollision(Collider, Collider) ThrowHook:Update() (at Assets/ThrowHook.cs:43)

As far as I can tell I’m doing it exactly as Unity - Scripting API: Physics.IgnoreCollision says to do, but something is going wrong.

Any help would be appreciated. Thanks.

Once check whether you have activated Meshcollider and Box collider to the particular object for which you attach colliders to it.

The reason might be that the object in which the collider is attached to is not currently instantiated in the hierarchy or is not currently active.
Both of the colliders must be present in the scene at the same time when this function is called.