Stars are not spent as it is supposed to be


I don’t get any errors in unity and my code behaves pretty well until the star display reaches the same amount = defenderCost then it doesn’t get spend for that specific moment.
For example:
The game starts with 100 stars then I start to spend it until I couldn’t spend it anymore. Once it reaches 50 (defenderCost) then I try to spend it but the stardisplay isn’t deducted.

Is there anyone experiencing the same issue? If so, how to solve it?


Hi ryanren,

Have you already tried to add Debug.Logs to your code to see what is going on during runtime?

Hi Nina,

I’m not sure what I should Debug.Logs here.
I tried to debug.log the spend but it seems like it works fine.
Any other things that you would suggest me to debug.log?

Try to verify/falsify your assumptions by logging information into your console. For example, you wrote that the stardisplay was not deducted. Use Debug.Log to figure out if the stardisplay is connected with your variable. If the value in your console is null, the variable does not reference anything.

Are there any error messages in your console?

Thanks, Nina.
I found the bug in my spendstars method where my if statement only says stars > amount instead of >=

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms