Hello, guys,
Here’s my code. I basically wanted to wait a few seconds before loading the level so that the game could show the animation for the explosion. However, it doesn’t wait. And “After Wait” doesn’t show in the log. I hope you can help me. I’ve tried a bunch of things but nothing has worked so far.
void OnTriggerEnter (Collider otherObject){
PlayerScript playerScript = (PlayerScript) otherObject.gameObject.GetComponent("PlayerScript");
Instantiate (ExplosionPrefab, playerScript.transform.position, playerScript.transform.rotation);
Destroy (otherObject.gameObject);
Destroy(this.gameObject);
StartCoroutine (wait());
Application.LoadLevel(1);
}
IEnumerator wait(){
Debug.Log ("before wait");
yield return new WaitForSeconds (5.0f);
Debug.Log ("After Wait");
}