Make two lines of code execute simultaneously?

So I have these two lines of code:

yield WaitForSeconds(ReloadTime);
audio2.Play();

How would I make those two lines happen at the same time, so while it is waiting for the reload time to pass, it plays the audio? Thanks!

P.s - somewhat new to scripting, learning fast

1 Answer

1

Invert the order of the code, so audio2.Play() is first.

That makes it so that it plays too early, is there a way to delay it by a half second or so?

Invoke ("PlaySound", 0.5); yield WaitForSeconds(reloadTime); // stuff } function PlaySound () { audio2.Play(); }

You can just use WaitForSeconds twice, once before you play the audio and once after

Thanks, this worked as I hoped it would.

Sweet! ­­­