Need help with collision

I’m writing my own physics engine in unity as part of a university assignment. I’m tasked to simulate the movement of a pool ball in a pool table where it moves and hits a wall then bounces. I implemented by writing an AABB class and whenever the ball collides with any of the wall I reflect the velocity vector. However for some reason the ball remains stuck to the wall. When I tried to debug the issue apparently the calculations are so fast that the balls keeps on reflecting the velocity vector making it stationary. Is there any way to fix this?

private bool HitWall()
    {
        AABB collider = gameObject.GetComponent<AABB>();

        for (int i = 0; i < walls.Length; i++)
        {
            if (collider.IsColliding(gameObject, walls[i]))
                return true;
        }

        return false;
    }


private void WallReflection()
    {
        if (HitWall())
        {
            Vector3D newVelocity = Vector3D.Reflection(velocity, new Vector3D(-1, 0, 0));
            velocity = newVelocity;
            CalculatePosition();
        }
    }

You are sensing only that it is colliding, I presume that the AABBs are overlapping or not.

You probably want to sense that it was NOT colliding in the previous frame, plus that it IS colliding now.

That will make it so that even if it remains in the wall for a moment later, the “hit” will only happen once. It’s the difference between “enter” and “stay” in the Unity family of collision methods.

So I should make a bool and check if it was already colliding with the wall?