Help with time

Hi!
In an effort to learn it better, I have spent the last week or so working on pure scripting.
The one thing that has stumped me time and time again is…well time!
In the simplest way possible, how does one do things such as count seconds?

for example:
If I wanted something to instantiate every 15 seconds, how would I do this?
Or if I wanted something to rotate for 10 seconds, stop for 15 seconds, then rotate again for ten seconds, how would the scripting of this work?

I can make it rotate, and insantiate, move, change colour, ect.and I understand UnityScript/JavaScript fairly well, but i’m stumped when it comes to timing.
Any help would be greatly appreciated!
Thanks
-Chris

InvokeRepeating("MySpawnFunction", 0.0, 15.0);
yield MyRotateFunction(10.0);
yield WaitForSeconds(15.0);
yield MyRotateFunction(10.0);

–Eric

Thank you very much! can the same sort of thing be done using Time.time?

Yes, but it would be more complicated.

–Eric

This is in C# right? How would you do this in JavaScript?

Those are both in JS (or in the case of the top one, both).

C# requires yield return, and not just yield.

Your 10-seconds-rotate-15-seconds-stay example could be implemented like this :

var mfTimer : float = 10.0;
var mbRotating : boolean = true;

function Update()
{
	if( mbRotating )
	{
		// Rotate
		RotateStuff();
		
		// Update timer
		mfTimer -= Time.deltaTime;
		if( mfTimer <= 0.0 )
		{
			mbRotating = false;
			
			// Launch 15 sec timer
			mfTimer = 15.0;
		}
	}
	else
	{
		// Don't rotate
		
		// Update timer
		mfTimer -= Time.deltaTime;
		if( mfTimer <= 0.0 )
		{
			mbRotating = true;
			
			// Launch 10 sec timer
			mfTimer = 10.0;
		}
	}	
}

Awesome, thanks!