I want to create the above object that will rotate on z-axis following the direction of a finger. Like a dial. I have written the following code and attached it to that element:
private float rotationRate = 3.0f;
void Update()
{
// get the user touch input
foreach (Touch touch in Input.touches)
{
Debug.Log("Touching at: " + touch.position);
if (touch.phase == TouchPhase.Began)
{
Debug.Log("Touch phase began at: " + touch.position);
}
else if (touch.phase == TouchPhase.Moved)
{
Debug.Log("Touch phase Moved");
transform.Rotate(touch.deltaPosition.y * rotationRate,
-touch.deltaPosition.x * rotationRate, 0, Space.World);
}
else if (touch.phase == TouchPhase.Ended)
{
Debug.Log("Touch phase Ended");
}
}
}
But the element does not move at all. Any ideas?
EDIT:
Here is a gif for better understanding: