Player is moving through walls when force is added from a knockback script? *UNANSWERED*

I have a level where I knockback the player when they enter a box collider, using force to push them, and the player can sometimes get shot through the level walls and floor if the knockback object it hit at some angles angle. I do not want this to happen. How can I keep the player from getting thrown through the walls?

Here is the knockback script

    public float force = 3;

    void OnCollisionEnter(Collision col)
        if (col.gameObject.tag == "Player")
            Vector3 dir = (col.contacts[0].point - transform.position).normalized;
            col.rigidbody.AddForce(dir * force);

On the rigidbody, set the collision detection to continuous

You can add the additionals box colliders of the same size and shape as the walls. That should do it. Aswell check if the “Is trigger” box is unchekd, otherwise it might be a reason behind it.

I’m curious about this physics-related question too, as sometimes I get the same kinds of issue.