Hello, I don’t know what is wrong with this code but here it is:
Vector3 dir = Input.mousePosition - Camera.main.WorldToScreenPoint(transform.position);
float angle = Mathf.Atan2(dir.y, dir.x) * Mathf.Rad2Deg;
transform.rotation = Quaternion.AngleAxis(angle, Vector3.forward);
And here is the problem:
https://imgur.com/a/LtoNc
Gameobject is rotated about 90 degrees.