Hi,
I am moving a 2D object on same direction and on same force as user swipe on screen for iOS in Unity4.3 as my following code show but it takes swipe on whole screen. Now I want to move object only when user swipe on object like user pick object with finger and throw him on desire direction. Here is following code but it take swipe whole screen, I want to take swipe just on desire object.
if(Input.touchCount>0 && Input.GetTouch(0).phase == TouchPhase.Moved)
{
Vector2 touchdeltaposition = Input.GetTouch(0).deltaPosition;
anglex = (float) (touchdeltaposition.x * Time.deltaTime *10.0);
angley = (float) (touchdeltaposition.y * Time.deltaTime *10.0);
elevationAngle = new Vector3(anglex,angley,0);
Vector3 elevation = Quaternion.Euler(elevationAngle)*transform.forward;
rigidbody2D.AddForce(elevation);
rigidbody2D.velocity= new Vector2(anglex,angley);
}
Thanks in advance, this will help me a lot.