Beispiel #1
0
    void OnCollisionEnter2D(Collision2D collision)
    {
        if (collision.collider.tag == "Goal")
        {
            return;
        }


        gameOverScript.TakeCrashDamage();

        foreach (ContactPoint2D contact in collision.contacts)
        {
            CrashParticles.Play();
            GameObject.FindGameObjectWithTag("MainCamera").transform.localPosition = new Vector3(
                GameObject.FindGameObjectWithTag("MainCamera").transform.localPosition.y + Random.Range(-0.1f, 0.1f),
                GameObject.FindGameObjectWithTag("MainCamera").transform.localPosition.y + Random.Range(-0.1f, 0.1f),
                GameObject.FindGameObjectWithTag("MainCamera").transform.localPosition.z);
            explosion.Play();
            StartCoroutine(ParticleWait());
            break;
        }
    }