Hey there fellow Unity devs!
I’ve having an issue with a coin payment script. I’m developing a small program that takes 25 coins to reveal a fortune. The payment script works but there’s a snag. When the coins are less than 50 it switches to the else part of the method which says “not enough”. This doesn’t make sense because it’s clearly stated that fortunes are 25 coins.
public int currentCoins;
public int fortunePrice = 25;
public int newAmnt;
public gameObject mainChart;
void payFortune(){
currentCoins = PlayerPrefs.GetInt ("coins");
newAmnt = currentCoins -= fortunePrice;
if(currentCoins >= 25) {
PlayerPrefs.SetInt ("coins", newAmnt);
PlayerPrefs.Save();
mainChart.SendMessage("ask");
}
else {
mainChart.SendMessage("notenough");
}
}
}
Any insights? You guys help would be greatly appreciated!