Wait time after coroutine's wait seconds is complete
Im trying to pause the game have some animations play and then resume.
IEnumerator wait()
{
player.GetComponent<PlayerController> ().setTime (0);
deathCon.stop (true);
Banner.SetActive (true);
Debug.Log ("before stop");
lerp = true;
yield return new WaitForSecondsRealtime(3);
Debug.Log ("after stop");
lerp = false;
nextLev = Random.Range (1, 3);
transform.position = new Vector3 (0, (nextLev * -20) , -10);
player.GetComponent<Rigidbody2D> ().velocity = new Vector2 (0, 0); //Reset Velocity
deathCon.setDeath (new Vector2 (0, (nextLev * -20)-7), true, 0.2F); //Set deaths stats ((x,y), grow along Y axis, speed)
player.transform.position = new Vector2(levels[nextLev].getPlayerPosX(), (levels[nextLev].getPlayerPosY() - 20 * nextLev));
goal.transform.position = new Vector2 (levels[nextLev].getGoalPosX(), (levels[nextLev].getGoalPosY() - 20 * nextLev)); //Move Goal
Banner.SetActive (false);
//deathCon.stop (false);
//player.GetComponent<PlayerController> ().setTime (1);
Debug.Log ("finnished stop");
}
With the two lines commented out everything works fine, but without them commented out the coroutine has about a 1.5 second wait time added to the end where player timescale = 0. This only happens when setting the players time to 1 or deaths time to 1. Any way to get rid of this wait time at the end?
Comment