TWO PLAYER TOP DOWN - STOP PLAYERS RUNNING OFF SCREEN

You could have your camera zoom in and out dependent on the distance between the players (smooth average between the two) and then limit the distance they can be apart from each other by measuring the difference in distance and giving a branch if greater than distance then movement wouldn’t work?