I have a spawn function thats called every time my player dies. It basically turns off all the colliders and renderers on my player, moves it to a ‘spawn point’ wait a few seconds, and turns the player back on.
Is it possible to have this function to wait until a certain external variable is true, and then carry on?
So, right now it does:
Turn off player
Move player
Wait a few seconds
Turn player on
I now want it to do:
Turn off player
Move player
Wait until ‘blah’ is true
Turn player on
If your wondering… that ‘Blah’ is a weapon list that pops up when you die, and when the player selects the weapon he wants, ‘blah’ comes true. Thus then continuing to spawn the player.
I know theres all sorts of different methods. But I really want to know if a form of ‘yield’ is possible?
Note: I love the async/await paradigm (having used it in javascript/typescript) but I only recently started using it C# Unity so I’m not sure of any side-effects but haven’t come across any so far. Makes the code soooo much cleaner IMHO.