I have a 2D sprite which I want to look at the mouse:
Vector2 mousePos = Input.mousePosition;
sprite.transform.LookAt (mousePos);
(these are in a loop, btw)
That rotated on the wrong axis. That was pretty easy to fix, though:
Vector3 spriteAngles = Vector3.zero;
spriteAngles.z = -newCity.transform.localEulerAngles.x;
sprite.transform.localEulerAngles = newCityAngles;
That worked. If I moved the mouse in a circle, the sprite moved too. The problem was that it would frequently not move with the mouse. It would move slower or faster than the mouse, or go the complete opposition direction of the mouse, and then change direction once the mouse completed a circle. How would I fix this so it looks directly at the mouse always? My game is on the XY plane, so I want a rotation around the Z axis.