I am having some issues with the multitouch in Unity iPhone. I want to apply the following script onto two objects such that I can move my both object at the same time with two different fingers. But whenever I touch one object, other object wont work.
Attached is a screen shot to give a clear understanding of what I am trying to do. I want to rotate the two circles at the same time using two different fingers. I tried having both access from the same script and having two separate scripts, both doesnt solve my problem
var Palette : GameObject;
var prevVecX : float;
var diff: float;
var spinSpeed : int = 360;
function Update ()
{
var hit : RaycastHit;
var ray = Camera.main.ScreenPointToRay (Input.mousePosition);
for (var i = 0; i < iPhoneInput.touchCount; ++i)
{
if (Physics.Raycast (ray, hit, 1000))
{
if ( hit.collider == Palette.collider )
{
if (iPhoneInput.GetTouch(i).phase == iPhoneTouchPhase.Began)
{
Debug.Log("U touched right");
}
if (iPhoneInput.GetTouch(i).phase == iPhoneTouchPhase.Stationary)
{
prevVecX = iPhoneInput.GetTouch(i).position.x;
}
if (iPhoneInput.GetTouch(i).phase == iPhoneTouchPhase.Moved)
{
diff = iPhoneInput.GetTouch(i).position.x - prevVecX;
if(diff >= 0)
{
Palette.transform.Rotate(Vector3.up * Time.deltaTime * spinSpeed);
}
else
{
Palette.transform.Rotate(Vector3.up * Time.deltaTime * -spinSpeed);
}
}
if (iPhoneInput.GetTouch(i).phase == iPhoneTouchPhase.Ended)
{
Debug.Log("Released");
}
}
}
}
}