Hey guys !
I’m reproducing touch gesture my sprite …
I already did the double tap to zoom in, the pinch and the drag.
I’m currently working on the rotation using two fingers.
I already recognize the fingers, get their position and try to interpret it correctly but so far i didn’t get anything real correct …
Here is what u did :
private void HandleRotation()
{
var f1 = new Touch();
var f2 = new Touch();
for (var i = 0; i < Input.touchCount; i++)
{
var wp = Camera.main.ScreenToWorldPoint(Input.GetTouch(i).position);
var touchPos = new Vector2(wp.x, wp.y);
if (collider2D == Physics2D.OverlapPoint(touchPos))
{
if (this._fingerIndex == 0)
{
this._fingerIndex += 1;
f1 = Input.GetTouch(i);
}
else
{
f2 = Input.GetTouch(i);
}
}
}
if (f1.phase == TouchPhase.Moved || f2.phase == TouchPhase.Moved)
{
var turnAngleF1 = Vector2.Angle(f1.position, f1.deltaPosition);
var turnAngleF2 = Vector2.Angle(f2.position, f2.deltaPosition);
var turnAngle = (turnAngleF1 + turnAngleF2) / 2;
Debug.WriteLine(turnAngle);
transform.Rotate(0, 0, turnAngle * 0.04f);
}
}
I figured that when you rotate something with your two fingers, you two fingers does not move at the same speed i then try to ponder the result by adding the two of them and divide the result by 2.
The weird thing is that my turn angle is ALWAYS between 90 and 145, that’s the first thing i don’t really get since my finger are almost not moving.
Second thing i’d like to ask is, how do i figure if my rotation is clockwise or not ?
Thank you for reading and helping.
Bottus.