Example #1
0
    void OnTriggerEnter2D(Collider2D col)
    {
        if (col.gameObject.CompareTag("Enemy") && thrown || col.gameObject.CompareTag("Shot") ||
            col.gameObject.CompareTag("bullet") || col.gameObject.CompareTag("Magnet"))
        {
            Debug.Log("Collision with " + col + " nothing should happpen");
        }

        else if (col.gameObject.CompareTag("ThrownCar"))
        {
            Rigidbody2D carRB = gameObject.GetComponent <Rigidbody2D>();
            knockback = carRB.velocity;
            carRB.AddForce(-knockback * 0);
            collision = true;
        }

        else if (col.gameObject.CompareTag("Player") && !collision && thrown)
        {
            collision = true;
            Debug.Log("Thrown car hit player");
            if ((ps.healthCurrent - carDamage) > 0)
            {
                dazed     = true;
                dazedTime = Time.time + dazedLength;
            }

            ps.RemoveHealth(carDamage);
        }
        else
        {
            Debug.Log("Collsion with other " + col);
            collision = true;
        }

        flickerTimer = Time.time + dazedLength;
    }