I'm making a split-screen 2D platformer (looks 3d but plays in 2D axis) where you aim and shoot with the mouse, and player 2 also aims and shoots with the mouse, but in his screen (it's network multiplayer).
My problem is that to make the split screen I'm using the Render-to-Texture function of the Camera. Basically i placed 2 cameras wich render to two textures, and in turn theese are placed on a plane in front of the Main Camera. Since I do it this way, the mouse coordinates are never really on your screen, they're on the Main Camera's screen.
So how can you tell the mouse to work on the camera/screen you want instead of the Main one? Or is there another way to solve this?
Not quite sure what you mean by "tell the mouse to work on".
You have mouse input in pixel coordinates with `Input.mousePosition` and the amount of the screen that each of your split screen cameras' render textures is occupying. From there it should be a snap.
I'm not sure why you're using a renderTexture instead of simply specifying the Camera.Rect or Camera.pixelRect for your cameras, but whatever works for you.
//using Camera.pixelRect or Camera.Rect
var cursor : Vector3 = Input.mousePosition;
//using Camera.pixelRect or Camera.Rect
//Assuming it's a vertical split
if(cursor.x > Camera1.pixelWidth)
//do something with Camera1
else
//do something with Camera2
Using a renderTexture on a plane, you would need to get the coordinate on the plane that the mouse is over. You would do this either by a raycast and using the hit point or by an assumed coordinate space (because the camera perspective projection will bend your coordinates) or if your main camera is orthographic, fairly easily by getting the world coordinates of your cursor and then comparing against the known size and position of the plane. In all of these solutions, you would use `mainCamera.ScreenToWorldPoint`. Once you know which point on the plane your mouse is over, you can easily convert that to a coordinate on your split screen camera by taking the coordinate on the plane and subtracting the coordinate where the camera starts on the plane.