Coroutines
Coroutines are like functions except run in the background, while normal functions will interrupt the game until the function is completed. Coroutines can make use of the wait keyword in order to pause the function without blocking the game.
Below is an example of a coroutine that runs a cutscene. The wait calls allow the function to pause in the background without interrupting the main execution. To call coroutines you can call them just like any other function.
coroutine Start()
{
Cutscene.ShowDialogue("Levi1", "Levi", "Defeat the female titan before she escapes the forest!");
wait 1.0;
if (Network.IsMasterClient)
{
annie = Game.SpawnShifterAt("Annie", spawn.Position);
}
wait 4.0;
}
You can also use wait on coroutine function calls, to wait until that coroutine is done.
coroutine Start()
{
wait self.CutScene1();
if (Network.IsMasterClient)
{
annie = Game.SpawnShifterAt("Annie", spawn.Position);
}
}
coroutine Cutscene1()
{
Cutscene.ShowDialogue("Levi1", "Levi", "Defeat the female titan before she escapes the forest!");
wait 1.0;
{
Last updated