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 !