예제 #1
0
    private void OnCollisionEnter(Collision collision)
    {
        if (ignoreNextCollision)
        {
            return;
        }

        if (isSuperSpeedActive && !collision.transform.GetComponent <Goal>())
        {
            Destroy(collision.transform.parent.gameObject, 0.2f);
        }
        else
        {
            //Death Parts
            DeathPart deathPart = collision.transform.GetComponent <DeathPart>();
            if (deathPart)
            {
                deathPart.HitDeathPart();
            }
        }



        rb.velocity = Vector3.zero;
        rb.AddForce(Vector3.up * impulseForce, ForceMode.Impulse);

        ignoreNextCollision = true;

        Invoke("AllowCollision", 0.2f);

        perfectPass        = 0;
        isSuperSpeedActive = false;
    }
    private void OnCollisionEnter(Collision other)
    {
        if (ignoreNextCollision)
        {
            return;
        }
        if (isSuperSpeedActive)
        {
            if (!other.transform.GetComponent <Goal>())
            {
                Destroy(other.transform.gameObject, 0.3f);
            }
        }
        else
        {
            //instance of class death part
            //also adding resetting level functionality when deathpart is hit
            DeathPart deathPart = other.transform.GetComponent <DeathPart>();
            if (deathPart) // if death part exists
            {
                deathPart.HitDeathPart();
            }
        }


        FindObjectOfType <AudioManager>().Play("PlayerHit");



        rb.velocity = Vector3.zero; // Remove velocity to not make the ball jump higher after falling done a greater distance
        rb.AddForce(Vector3.up * impulseForce, ForceMode.Impulse);

        ignoreNextCollision = true;
        Invoke("AllowCollision", 0.2f);

        perfectPass        = 0;
        isSuperSpeedActive = false;
    }