a question about rotation & how to get the rotation back to it's default value

I am new to unity, and don't know many functions or anything yet. Coding in javascript. I'm using this code to rotate an object:

gameObject.transform.Rotate(rot_x,0,rot_z);

The player changes the rotational variables with the Horizontal and Vertical buttons. Now to the problem: This rotates the in a way that it adds rot_x and rot_z to the rotation every step, and I can't rotate it back to where it was to start with (0,0,0). My plan was to multiply the rotation values with 0.95 to get it to turn back smoothly to 0,0,0.

How do i do this? What do i multiply with 0.95 to get the effect i want? it is obviously the X rotation of the gameObject, but how to write it?

Try doing a Quaternion.Slerp to interpolate. You'll need to cache the 'original' rotation (where the object is before you come back) before you start the 'slerp' process. This will smoothly rotate the object back to quaternion.identity over time (based on the 'speed' variable).

Edit: Make sure you set speed higher than 0.

private var originalRotation : Quaternion;
private var newRotation : Quaternion;
var speed : float;
private var t : float;
private var slerping : boolean;

function StartSlerp()
{
   originalRotation = gameObject.transform.rotation;
   newRotation = Quaternion.identity;
   slerping = true;
   t = 0;
}

function Update()
{
   if(slerping)
   {
      if(t < 1)
      {
         gameObject.transform.rotation = Quaternion.Slerp(originalRotation, newRotation, t);
         t += Time.deltaTime * speed;
      }
      else
      {
         slerping = false;
      }
   }
}

I assume you want to instantly reset the rotation. Try:

gameObject.transform.rotation = Quaternion.identity;

Well, does "instantly" mean it will sort of "jump" back to the default value? I'd rather want it to somehow smooth back into it. is there a way i can use Quaternion.identify to do this?

....

by the way.. I tried this script: gameObject.transform.rotation = Quaternion.identity;

It gave me an error. Do i need to exchange Quaternion with something else?