Rotating Gameobjects on a scene with more than 1 Camera ?

hey guys… ! I have a scene in which there are 3 sections which are displayed using 3 cameras. I want to rotate Game Object that are displayed from the Main Camera using gestures .Rotating is happening perfectly. But when user swipes in the section that is rendered using other camera Game Objects rotates which i dont want . I am using raycasting for this purpose but still it happens. Here is the script that is attached to the background and tried by attaching to the camera as well.

var targetItem : GameObject;

var rotationRate : float = 1.0;
var hit: RaycastHit;
public var background:GameObject;
public var cam:Camera;

var smooth = 1.0;
var tiltAngle = 30.0;

function Update()
{
	if (Input.touchCount > 0) 
    {
         var theTouch : Touch = Input.GetTouch(0);
         var ray = cam.ScreenPointToRay(theTouch.position);
         if(Physics.Raycast(ray,hit))
         {
         	if(hit.collider==background.collider)
		 	{	
		 		if(Input.touchCount == 1)
            	{
 					if (theTouch.phase == TouchPhase.Moved) 
    	           	{
    	           		//this code is for x-axis rotation
    	           		if(Input.GetTouch(0).deltaPosition.y < 0|| Input.GetTouch(0).deltaPosition.y > 0)
						{
							targetItem.transform.Rotate(theTouch.deltaPosition.x * rotationRate,0,0,Space.World);
						}
    	           		if(Input.GetTouch(0).deltaPosition.x < 0  || Input.GetTouch(0).deltaPosition.x > 0)
						{
							targetItem.transform.Rotate(0,theTouch.deltaPosition.y * rotationRate,0,Space.World);
						}
            	    }    
         		}
         	}	
		}
    }
}

It seems like you’re using the wrong variables to rotate:

if(Input.GetTouch(0).deltaPosition.y < 0|| Input.GetTouch(0).deltaPosition.y > 0)
{
	targetItem.transform.Rotate(theTouch.deltaPosition.x * rotationRate,0,0,Space.World); // you rotate based on the touch movement on X. You want to use theTouch.deltaPosition.y, which you checked in the if statement.
}

if(Input.GetTouch(0).deltaPosition.x < 0  || Input.GetTouch(0).deltaPosition.x > 0)
{
	targetItem.transform.Rotate(0,theTouch.deltaPosition.y * rotationRate,0,Space.World); // you rotate based on the touch movement on Y. You want to use theTouch.deltaPosition.x, which you checked in the if statement.
}

If you want to limit the rotation algorithm only to touches in a certain camera’s viewport you can use Camera.ScreenToViewportPoint :

You can use it to check if the current touch position is within the camera you want to use for rotating:

Vector3 touchVP = rotateCamera.ScreenToViewportPoint(theTouch.position);
if (touchVP.x < 1 && touchVP.y < 1 && touchVP.x > 0 && touchVP.y > 0) {
    // rotate here
}