Hi, I would like to play a sound when the player enter the collider and then after 10 sec only the second coroutine will call. but unfortunately it seems that coroutine is running at the same time(there is no delay). below is the code. Hope somebody can help me. PLEASE…
void OnTriggerEnter( Collider col)
{ if (col.gameObject.tag == “Player” )
{
StartCoroutine("AudioStart");
StartCoroutine("WaitHere");
} // end if
//FPCStart.ansq++;
//Debug.Log (GameControl.control.ansq++);
}//end function on trigger enter
IEnumerator AudioStart()
{
audio.clip = StartAns;
audio.Play ();
yield return new WaitForSeconds (10.0f);
}// end function AudioStart
IEnumerator WaitHere()
{ float timeLeft = 0.0f;
while (timeLeft<10.0f && !Ans)
{
timeLeft += Time.deltaTime;
Fig.SetActive (true);
if (Input.GetKeyDown(KeyCode.Y))
{
GameControl.control.correctAns +=1;
GameControl.control.Correct();
Ans = true;
}
else if (Input.GetKeyDown(KeyCode.T))
{
GameControl.control.wrongAns +=1;
Ans =true;
}
yield return null;
}// end while
Destroy (Fig);
if (Ans == false)
{
audio.clip = endGame;
audio.Play ();
}
}// end ienu