Upgrades that require previous upgrades?

Hi guys,

I’m creating a clicker game (YAY I know). But I want to make the moneypersecond upgrades require a certain amount of moneyperclick items before it can be bought.

E.g. To buy Upgrade1 requires, Item x 5.

Any help please? :slight_smile: I’m still new to coding so this game is my practice essentially. :slight_smile:

without knowing anything about how you’ve setup you scene/project because you’ve not included much detail… assuming “Item” is a component class attached to the things you are trying to count

Item[] things = FindObjectsOfType<Item>();
if(things.Count >= 5)
{ 
//stuff

This is the “items” script;

void Update() {
    itemInfo.text = itemName + "\nCost: " + cost + "\nPower:" + clickPower;
}

    public void PurchasedUpgrade(){
        if  (click.money >= cost) {
            click.money -= cost;
            count += 1;
            click.moneyperclick += clickPower;
            cost = Mathf.Round(cost * 1.30f);
            newCost = Mathf.Pow (cost, newCost = cost);
        }

    }
}

And here’s the “Upgrade” script;

 // Use this for initialization
    void Start()
    {
        baseCost = cost;
    }

    // Update is called once per frame
    void Update()
    {
        itemInfo.text = itemName + "\nCost: " + cost + "\nMoney: " + tickValue + "/s";

           }

    public void PurchasedUpgrade()
    {
         if (click.money >= cost)
        {
            click.money -= cost;
            count += 1;
            cost = Mathf.Round(baseCost * Mathf.Pow(1.30f, count));
          
        }