Hi guys. First of all sorry for my worse English.
I try to make rotate a sprite with mouse drag. I can do it. The script is at below. But the problem is when mouse button down the sprite rotates immediately to the mouse position. I want a rotation with relative to mouse position. I dont want to chase mouse position.
Thanks a lot.
private void Update()
{
pos = Camera.main.WorldToScreenPoint(transform.position);
dir = Input.mousePosition - pos;
angle = Mathf.Atan2(dir.y, dir.x) * Mathf.Rad2Deg;
if (Input.GetMouseButton(0))
{
transform.rotation = Quaternion.AngleAxis(angle, Vector3.forward);
}
}