How to make a ball move in a zigzag wall along the y-axis without falling?

I’m making a simple 2d game where a ball can move in a zigzag wall along the y-axis .I need to make the ball stick to the wall . Thank you

RidgidBody Component lock axis. check the boxes that the ball shoudnt move.