- Home /
Question by
aleem.razzaq09 · Dec 10, 2013 at 05:31 AM ·
2dswipeunity4.3
Pick 2D object with touch in Unity 4.3
Hi, I want to pick an object (2D) with touch and move object swipe this with finger in Unity 4.3. Currently I am moving object with swipe on whole screen but I want to move object with swipe on desired object. I am doing moving object with swipe. 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);
//if(anglex>0)
rigidbody2D.velocity= new Vector2(anglex,angley);
}
Comment