accessing .NET functions in Unity ?

Thread.Sleep(n) in .NET C# will pause for n milliseconds.
Can I access this from JavaScript and add a delay within an Update() function ?

I suspect I can’t as the whole game would pause ?

Help me out here please.

http://forum.unity3d.com/viewtopic.php?t=931

–Eric

Yes it works and as I guessed, it stops rendering for the time in the function call. No good a situation where you want, say, a rotation then a pause, then ressumption of the rotation etc

What I really wanted was the equiverlent of 3D GameStudio’s:

wait(2); // pause for 2 frames
or
wait(-2); // pause for 2 seconds

Thanks

coroutines?

Hi teatime

Could you show me how to achieve this:

function Update()
{
transform.Rotate(0,0,1);

pause for 2 seconds

}

[/code]

Don’t use Update, use coroutines and yield…i.e., “yield WaitForSeconds(2.0);”

–Eric

function rot_me ()
{
yield WaitForSeconds (2);
transform.Rotate(0,0,1);
}

how do I call this if I can’t put it in function Update()

StartCoroutine(rot_me());

StartCoroutine(rot_me());

function rot_me ()
{
yield WaitForSeconds (2);
transform.Rotate(1,0,0);
}

where to I apply it ? I put it on the cube and it doesn’t do anything ?

this way of programming is like a ‘black art’ to me

the code was meant as replacement for your attempt to use the yield directly.