Ejemplo n.º 1
0
    public void OnCollisionEnter(Collision collision)
    {
        if (collision.gameObject.CompareTag("CarTraffic"))
        {
            isActive     = false;
            Acceleration = 0;

            if (isFirstImpact)
            {
                source.PlayOneShot(grannyAudio1, 0.3f);
                FindObjectOfType <AudioManager>().Play("Crash");
                isFirstImpact = false;

                StartCoroutine(gameManager.AccidentCountdown());
                rb.velocity = transform.TransformDirection(0, 12, -6);
            }
        }

        if (collision.gameObject.CompareTag("Buildings"))
        {
            isActive     = false;
            Acceleration = 0;

            if (isFirstImpact)
            {
                source.PlayOneShot(grannyAudio1, 0.3f);
                FindObjectOfType <AudioManager>().Play("Crash");
                isFirstImpact = false;

                StartCoroutine(gameManager.AccidentCountdown());
                rb.velocity = transform.TransformDirection(0, 4, -6);
            }
        }
    }