Exemplo n.º 1
0
    IEnumerator RespawnBall(Collider c)
    {
        StartCoroutine(gameGui.ShowMessage(
                           (isBlue ? "Blue" : "Red") + " scored " + points + " points!"));

        if (isBlue)
        {
            gameGui.blueScore += points;
        }
        else
        {
            gameGui.redScore += points;
        }

        yield return(new WaitForSeconds(0.5f));

        var respawnPoint = respawnPoints[Random.Range(0, respawnPoints.Length)];
        var pointOffset  = new Vector3(
            Random.Range(-respawnRandomRange, respawnRandomRange),
            0,
            Random.Range(-respawnRandomRange, respawnRandomRange));

        c.transform.position = respawnPoint.position + pointOffset;
        c.GetComponent <Rigidbody>().velocity        = Vector3.zero;
        c.GetComponent <Rigidbody>().angularVelocity = Vector3.zero;
    }