Raycast and splitScreen

Hello,
I’m currently creating a 2D app where you can grab some objects via a raycast. When the raycast returns an object, I launch a “StartDragging” function on it.
It’s working very well, but I decided to created a split screen mode, in which I have 3 camera displayed on my screen. (a panoramic camera on the top of the screen, and 2 player-centered cameras on the bottom). As I am using this mode, my raycast do not work anymore. I do call the “ScreenPointToRay” function on the good camera, but my raycast never touches any snowball.
When I switch back to a normal mode, it’s working again.

var mouseRay : Ray = currentCameraGet(touch).ScreenPointToRay(touch.position);
            Debug.Log("LaunchRay From "+currentCameraGet(touch).name+" Position = "+touch.position);
            var rayHit : RaycastHit;
            
            //Touch only layer9 (snowball)
            var layerMask1 = 1 << 9;
            
            //If a snowball is finded via raycast, add it to the tracker
            if (Physics.Raycast(mouseRay.origin, mouseRay.direction, rayHit, Mathf.Infinity, layerMask1)){
...
}

I don’t understand what’s happening. I guess that it is because of the touch.position, which is based on a fullscreen.
So, I tried to convert my touch.position in order to make it fit with my camera position on the screen, but it wasn’t ok.

Has someone already encounter this problem ?

Thanks !

It is likely that the touch position is what’s causing the problem here. It can be tricky to get this right, depending on the arrangement of camera views, but you’ll probably find Camera.ViewportPointToRay helps out here. Viewport coordinates are specified as fractions from 0 to 1, with <0,0> as the bottom left corner and <1,1> as the top right. Basically, you need to subtract the point where the view starts from the touch position and then divide the result by the width and height of the view to get the viewport coordinate.