Sorry I’m new to this,
I am trying to rotate a circle from A to B with mouse.position, but I would like that the next time I receive a new mouse.position the circle rotates in z from the last position (B) to C, can someone help me ?
Thanks
current code:
Vector2 positionOnScreen = Camera.main.WorldToViewportPoint(transform.position);
Vector2 mouseOnScreen = (Vector2)Camera.main.ScreenToViewportPoint(Input.mousePosition);
angle = AngleBetweenTwoPoints(positionOnScreen, mouseOnScreen);
//apply Rotation
transform.rotation = Quaternion.Euler(new Vector3(0f, 0f, angle));
float AngleBetweenTwoPoints(Vector3 a, Vector3 b)
{
return Mathf.Atan2(a.y - b.y, a.x - b.x) * Mathf.Rad2Deg;
}