In my script I need a delay, but I can’t use the coroutine. I am a little confused with this problem, so I can’t describe, why I can’t use coroutine. I just need a delay between case 2 and case 3.
void Update()
{
if (Input.GetKeyDown(KeyCode.P))
shouldIncreaseLadder = true;
if (shouldIncreaseLadder)
{
switch(increaseLadderCallNumber)
{
case 0: IncreaseLadderGroupSize(ladderGroup0); break;
case 1: IncreaseLadderGroupSize(ladderGroup1); break;
case 2: IncreaseLadderGroupSize(ladderGroup2); break;
// I need to call this function after delay in 2 seconds
case 3: IncreaseLadderGroupSize(ladderGroup10); break;
case 4: IncreaseLadderGroupSize(ladderGroup11); break;
default: break;
}
}
}
void IncreaseLadderGroupSize(GameObject[] ladderGroupArray)
{
foreach (GameObject i in ladderGroupArray)
{
//.. some code ..
shouldIncreaseLadder = false;
}
shouldIncreaseLadder = true;
isLadderGroupDone = false;
}