Hey all! I am working on a clicker game and am implementing an auto click upgrade. Right now the code below has it set up that after I make the first purchase, every second I am “paid” points equivalent to the upgrade tier I am at. 1 upgrade = 1 point a second, 2 upgrade = 2 points a second, 3 = 3, etc.
public void autoClick()
{
InvokeRepeating("Payout", 1f, 1f);
}
public void Payout()
{
gm.Money = gm.Money + (upgradeTier -1);
}
This all works fine, expect for the fact that because of Invoke, I am receive the points in 1 lump sum ever second. If i am at upgrade tier 2, it looks as though the score is counting up by 2 points. My goal is to set up a system in which the score counts or ticks up to pay out the correct amount every 1 second, but ticks up 1 point at a time. If it needs to pay 2 it will tick up by 1 point every 0.5f, if it is by 3 it will tick up every 0.33f etc.
I tried something like this below but it only results in being paid out 1 time, and never again.
public void autoClick()
{
InvokeRepeating("Payout", 0f, (1 / (upgradeTier - 1)));
}
public void Payout()
{
gm.Money = gm.Money + 1;
}
Advice would be helpful!
A side note is that it is set up that when the upgrade is purchased the first time it called autoClick() only once. Every other purchase or upgrade should not be calling autoClick() again.