How can I Lerp the Rotation of my Game Object to my Mouse Pointer?

Hi,
I have just started programming a top down shooter game and I have almost set up the player character. All there is to do now is to make the character Lerp to face the direction of the mouse relative to the character’s current position. I have written this script, taken from a few other peoples questions on Unity Answers, which I think should work so I don’t understand why it doesn’t.

// Create target rotation facing mouse pointer
		Vector3 pos = Camera.main.WorldToScreenPoint(transform.position);
		Vector3 dir = Input.mousePosition - pos;
		float angle = Mathf.Atan2(dir.y, dir.x) * Mathf.Rad2Deg;
		targetRotation = Quaternion.AngleAxis(angle - 90f, Vector3.forward);

		// Lerp to target rotation
		transform.rotation = Quaternion.Lerp(transform.rotation, targetRotation, Time.time * turnSpeed);

As you can see by the first section of code, my target rotation is set to face the mouse pointer. Then in the second section of code you can see I try to lerp my transform.rotation to the target rotation. It does definitely rotate to face the mouse but instead of lerping it to that rotation all the time, it starts off lerping it slowly then gradually speeds up the lerp speed over time until it becomes impossible to even notice the lerp. If anyone can help me it world be much appreciated.

Many Thanks,

Tommy Eaves

Have you tried replacing “Time.time” with “Time.deltaTime”?