Lock an axis?

Using spheres on a 2D game is giving me trouble with collision. I want them to bounce off of each other, but I need them to stay on X and Y. After a few collisions they get a little off and move on the Z axis and it no longer works… is there a way to lock them to a Z position?