Split screen help!

More my multiplayer game, how could I add a way to make the screen split only If the players move away from each other, so if they are all on the screen it would be 1 screen, if 2 were at the top of the map and 2 were on the bottom the screen would split vertically, or horizontally if its left and right.