I have made a pong game in which a ball collides with the right wall and then destroys, and then awards 1 point to the opponent. Then i need to make the game stop for some seconds and then restart the layout. My script is:
function OnCollisionEnter (col : Collision)
{
if(col.gameObject.name == "rightWall")
{
Destroy(gameObject); //Destroys the object
GameMaster.score_P2 +=1; //Adds one to the score
StartCoroutine(stop());
}
}
function stop(): IEnumerator {
yield WaitForSeconds(2.0);
Debug.Log('waited for 2 seconds');
}