Whether to work this code?

There is here such code
IEnumerator instObj ()
{
 (1) yield return new WaitForSeconds(1.5 f);
 (2) Instantiate(obj, new Vector3(Random.Range(-10f, 10f), 0, Random.Range(-10f, 10f)), Quaternion.identity);
 }


Will it work if you swap (1) and (2)
IEnumerator instObj ()
{
 (2)Instantiate(obj, new Vector3(Random.Range(-10f, 10f), 0, Random.Range(-10f, 10f)), Quaternion.identity);
 (1) yield return new WaitForSeconds(1.5 f);
 }
April 19th 20 at 12:23
1 answer
April 19th 20 at 12:25
Solution
Will. But strict logic will change too
And how to change? - marcelle.Glover commented on April 19th 20 at 12:28
@marcelle.Glover, 1 2 first, you wait 1.5 seconds code and create an object, and 2 1 will create the object once and then reference - Helen.Ferry81 commented on April 19th 20 at 12:31
@Helen.Ferry81, thank you - marcelle.Glover commented on April 19th 20 at 12:34

Find more questions by tags Unity Game EngineC#