Quantcast
Channel: Answers by "andresp"
Viewing all articles
Browse latest Browse all 14

Answer by andresp

$
0
0

add this to your code:

// do something
yield WaitForSeconds(3.0); // wait for 3 seconds
// do something more...

Source

EDIT - C# Example:

using UnityEngine;
using System.Collections;
public class test : MonoBehaviour {
    bool calledDelay = false;
    bool doneDelay = false;
    IEnumerator Wait(float sec)
    {
        yield return new WaitForSeconds(sec);
        Debug.Log("3 seconds later");
        doneDelay = true;
    }
    void Update () {
        if (doneDelay)
            Debug.Log("Do something");
        else if (!calledDelay)
        {
            calledDelay = true;
            StartCoroutine(Wait(3f));
        }
    }
}

Viewing all articles
Browse latest Browse all 14

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>