Quaternion.Lerp sprite rotation issue

I’m trying to rotate player back to it’s initial position after ship get’s hit from the side. I don’t really know whats wrong, but this function twitches my player back and forth instead of smoothly rotating back to it’s initial position.

This is what it looks like:
http://giphy.com/gifs/xT8qAZcxlCPlFlRBtu/fullscreen

My code:

using UnityEngine;
using System.Collections;

public class PlayerController : MonoBehaviour {

	// Movement
	public float thrustVertical = 2.0f; // Optimal 2
	public float thrustHorizontalLeft = -1.0f; // Optimal -1
	public float thrustHorizontalRight = 1.0f; //Optimal 1

	Quaternion desiredRotation;

	// Physics
	private Rigidbody2D rb2d;

	// Use this for initialization
	void Start () {
		rb2d = GetComponent<Rigidbody2D> ();
		desiredRotation = transform.rotation;
	}

	// Update is called once per frame.
	void Update () {
		transform.rotation = Quaternion.Lerp(transform.rotation, desiredRotation, Time.deltaTime * 10f);

	}

	// Rigidbody manipulation
	void FixedUpdate(){
		if (Input.touchCount > 0) {

			Touch touch = Input.GetTouch (0);
			float middle = Screen.width / 2;

			if (Input.touchCount == 2) {
				moveUp ();
			} else if (touch.position.x > middle) {
				moveRight ();
			} else if (touch.position.x < middle) {
				moveLeft ();
			}
		}
			
	}

	// Move character left
	private void moveLeft(){
		rb2d.AddRelativeForce (new Vector2 (thrustHorizontalLeft, 0));
	}

	// Move character right
	private void moveRight(){
		rb2d.AddRelativeForce (new Vector2 (thrustHorizontalRight, 0));
	}

	// Move character up
	private void moveUp(){
		rb2d.AddRelativeForce (new Vector2 (0, thrustVertical));
	}

}

This is caused when the physics system overrides the transform component’s rotation with it’s own.

Each update loop you change the transform.rotation and then when the physics system comes around it changes the transform.rotation to the rigidbody.rotation.

To fix this, replace the Update method with this:

var rot = Quaternion.Euler (0, 0, GetComponent<Rigidbody2D> ().rotation);
rb2d.rotation = Quaternion.Lerp(rot, desiredRotation, Time.deltaTime * 10f).eulerAngles.z;

Please note that angular momentum is still active so it won’t stop rotating only look like it is. Increase the angular drag on the rigidbody to stop this.