If i just want to "Time delay" 5 second...?

If i just want to “Time delay” 5 second…?

using UnityEngine;
using System.Collections;

public class Mover : MonoBehaviour {

public int i = 5;
void Update() {

       if (i >0){
          print (i);
          i = i - 1;
        // here i want to "Time delay"  1 second.
       }

}

}

Try the IEnumerator :slight_smile:

IEnumerator Example
{
yield return new WaitForSecond (5) ;
Example script
}

@ftnara ,Here is a simple example you can use for most timed purposes without going into the IEnumerator’s and that side of the logic.

using UnityEngine;
using System.Collections;

public class SimpleTimer : MonoBehaviour {

	public float myTimer;
	public bool timesUp;

	void Start() {
		timesUp = false;
	}

	void Update() {
		myTimer -= Time.deltaTime;

		if (myTimer <= 0) {
			timesUp = true;
			myTimer = 0;
		}

		if (timesUp) {
			// Do Something
		}
	}
}

Basically here we are just subtracting from our myTimer float via the Time.deltaTIme method. This will allow us by default to subtract 1 from the timer every second. Note, that if you change the Time.timeScale this may affect this logic.

Let me know if something isnt clear or if you need help.