Hi Everyone.
I’ve got a little problem.
I want to rotate my cam by using two fingers and twist (like when you rotate a picture in your smartphone)
this is the movement : http://www.logitech.com/assets/47070/rotate.png
i’ve already done the pinch to zoom, here is the code :
private float touchDelta = 0.0F;
private Vector2 prevDist = new Vector2(0,0);
private Vector2 curDist = new Vector2(0,0);
private GameObject obj;
private Camera cam;
void Start ()
{
obj = GameObject.FindGameObjectWithTag("TopCamera");
cam = obj.GetComponent<Camera>() as Camera;
}
void Update ()
{
if (Input.touchCount == 2 && Input.GetTouch(0).phase == TouchPhase.Moved && Input.GetTouch(1).phase == TouchPhase.Moved && Event.current.type == EventType.mouseDrag)
{
curDist = Input.GetTouch(0).position - Input.GetTouch(1).position;
prevDist = ((Input.GetTouch(0).position - Input.GetTouch(0).deltaPosition) - (Input.GetTouch(1).position - Input.GetTouch(1).deltaPosition));
touchDelta = curDist.magnitude - prevDist.magnitude;
if ((touchDelta <= 0))
{
cam.fieldOfView = Mathf.Clamp(cam.fieldOfView + 1.5f, 10, 60);
}
else if ((touchDelta > 0))
{
cam.fieldOfView = Mathf.Clamp(cam.fieldOfView - 1.5f, 10, 60);
}
}
}
Thanks ![]()
No One got the solution ? Thanks.
– tomtom789