GameObject won't "bounce" off wall

I am making a pong game, and I want the ball to bounce when it hits the edge of the screen. whenever the ball should bounce, it just goes straight past the edge and off the screen, and I don't get anything in the console.

I have a rigid body and a box collider on the ball, and a box collider on each edge that i want it to bounce. Here is the code, the x value of the vector 3 should just stay the same

Vector3 direction;

void OnCollisionEnter2D()
        direction.y = -direction.y;

Solved it myself

What did you do to solve it? Folk would like to know :smile: