Another way

I had accidentally covered the same problem in a different way, because I made a plan to have to deliver X packages of different colors to each customer. So last lecture I had written this, and it works perfect.

    if (other.tag == "BlueCustomer")
    {
        if (bluePackage >=1) 
        {
            blueDelivery = bluePackage;
            bluePackage = 0;
            Debug.Log(bluePackage);
            Debug.Log(blueDelivery);
        }
    }

Although looking and thinking about it, I need to do blueDelivery = blueDelivery + bluePackage; so if you deliver them separately you can get up to the max amount.

Privacy & Terms