Making a ball move sideways

Hi, I am working on a game where you must run through a course and dodge balls bouncing off the the walls. I could lock the ball in the x and z axis so that it would only move along the y axis. My question is how would I write a script for the ball that applies a side force to it that changes directions when it hits a wall?

Thanks for the help!

Dont know if you use C# or Javascript, but here is some reading for you:
Vector2