Transforming slowly

Hi there,

I’d like to be able to adapt something slowly. For example, the following code:

if (Input.GetKeyDown("z"))
		transform.eulerAngles = new Vector3(0, 0, 0);

I’ve attached that to my little car as a way of flipping it if lands on its roof. But it will just instantly change to that rather than slowly roll over. I’ve been looking into Slerp but I can’t seem to get my head around it.

Any info is a great help dudes.
Cheers

Here’s an example using smooth damp. In the inspector smoothTime was set to 2.0.

using UnityEngine;
using System.Collections;

public class Smooth : MonoBehaviour 
{
	public float smoothTime; // assign in inspector
	private bool flipping = false;
	private Transform thisTransform;
	private Vector3 vel = Vector3.zero;

	public void Start()
	{
		// cache this objects transform.  Otherwise small hits, under the covers GetComponent is used in < unity 5
		thisTransform = transform;
	}
	
	public void Update()
	{
		if (Input.GetKeyDown("z"))
			flipping = true;
		
		if(flipping && thisTransform.eulerAngles != Vector3.zero)
		{
			float speed = Time.deltaTime * smoothTime;
			thisTransform.eulerAngles = Vector3.SmoothDamp(thisTransform.eulerAngles, Vector3.zero, ref vel, speed);
		}
		else if (flipping && transform.eulerAngles == Vector3.zero)
		{
			flipping = false;
		}
	}

}