Question by
DrFragger · Mar 02, 2019 at 05:40 AM ·
instantiateienumerator
How Can i run a method afterequal integer number counts using Ienumerator ??
I want to run Path() method after every 42 counts of the blocks integer....
void Start() {
StartCoroutine(PreMadePath());
}
public IEnumerator PreMadePath()
{
blocks++;
yield return new WaitForEndOfFrame();
if (blocks<=50)
{
Path();
}
StartCoroutine(PreMadePath());
}
public void Path()
{
int R1 = Random.Range(0, 2);
tile = (GameObject)Instantiate(pathprefab, new Vector3(x1, 0, z1), Quaternion.identity);
int R2 = Random.Range(0, 12);
int booster = Random.Range(0, 80);
if (booster == 5)
{
if (R2 == 1)
{
tile.transform.GetChild(1).gameObject.SetActive(false);
}
else
{
tile.transform.GetChild(1).gameObject.SetActive(true);
}
}
if (R2 == 1)
{
tile.transform.GetChild(2).gameObject.SetActive(true);
}
if (R1 == 0)
{
x1 = x1 - 1;
}
else
{
z1 = z1 - 1;
}
Comment