My problem is that even thought the value of money is updating in it’s own function, the value of money will stay zero in the “if (cB == true)” function, I have tried many suggested solutions but the value of money still won’t update. I’m probably missing something obvious since I’m still new, any help is welcomed, thanks in advance.
public class moneyV2 : MonoBehaviour
{
public bool cB;
public bool cCB;
public bool sCB;
public bool mB;
public int money;
public int cN;
public int cCN;
public int sCN;
void start ()
{
cN = 1;
}
public void OnMouseDown ()
{
if (cB == true)
{
Debug.LogFormat("money = {0}", money);
if (money >= 10)
{
buyCow();
}
else
{
Debug.Log("money < 10");
}
}
if (mB == true)
{
money += cN;
Debug.LogFormat("money = {0}", money);
}
}
public void buyCow ()
{
money = money - 10;
cN++;
Debug.LogFormat("cN = {0}", cN);