I have a top-down 2D game. My player moves towards my mouse position on screen. I want my player to rotate smoothly when mouse position changes. I’m doing this:
void Update(){
Vector3 mouse = Input.mousePosition;
Vector3 screenPoint = Camera.main.WorldToScreenPoint(transform.localPosition);
Vector2 offset = new Vector2(mouse.x - screenPoint.x, mouse.y - screenPoint.y);
Float angle = Mathf.Atan2(offset.y, offset.x) * Mathf.Rad2Deg;
transform.rotation = Quaternion.RotateTowards(transform.rotation,Quaternion.Euler(0, 0, angle),Time.time);
}
when I go play, the player rotates smoothly everytime the mouse change position, but after a couple of seconds it starts to rotate faster everytime until is not an smooth rotation anymore. I want the speed rotation to be the same everytime. Dont know what is going on.