T
T
Taras Ivanov2020-10-02 19:41:04
C++ / C#
Taras Ivanov, 2020-10-02 19:41:04

The function does not work as expected. How to fix it?

Hello, I made it so that you could specify the price of the product and the bonus in the unit itself (I do it according to this guide https://www.youtube.com/watch?v=WOd22Az66SY&t=712s . This moment starts at about 14:00). Did everything right. I indicated both the price and the bonus, but when buying an improvement with enough funds, it gives an error in the log (Insufficient funds). The code:

[Header("Работа")]
    private int workersCount;
    public int [] rabotaCena;
    public int [] rabotaBonus;


    public void workPan_addClickerScore(int index)
    {
        if (score >= rabotaCena[index])
        {
            bonus += rabotaBonus[index];
            score -= rabotaCena[index];
        }
        else
        {
            Debug.Log("Ошибка");   
        }
          }

Screenshots:
5f77573bbd5a7584050753.png
5f77574e9abf0182661492.png
If anything, I'm new to game development. Do not judge strictly.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question