Subtracting variable amount over time?

How can I distract a variable over time?
For example:

var amount : int = 10;

Every second (declared in a variable so I can change the speed) the amount is subtracted by 1. Can anyone help me?

very simple, please learn about Invoke() and InvokeRepeating()

many beginner articles on this at unityGEMS.com

Here’s a simple way to do it:

var amount : int = 10;

in your Start() routine…

Invoke( "removeOneSecond", 1.0 );

write a simple routine like this:

function removeOneSecond()
  {
  if ( removeOneSecond < 0 ) return;

  removeOneSecond = removeOneSecond - 1;
  Debug.Log("removeOneSecond is now ... " + removeOneSecond);

  Invoke( "removeOneSecond", 1.0 );
  }

OK? So it’s that easy. Alternately you could use InvokeRepeating() and then when it is less than zero, CancelInvoke(). Cheers.