How to limit how far an object can move in Blender Game Engine?
You can make the wall invisible. Then make the cursor object a sensor physics type, and when it collides with the wall, have it send a message to the player to unparent. This method isn't fool proof (if you move the mouse too quickly, then the guy can clip through the wall.) but it's very simple to understand and I'm sure you can make the most of it.