Adding to integer too many times in a row (?)

Hi!

Sorry about the confusing title, not sure how to describe my issue.

So, I asked a while ago about adding to an integer, in the fashion that rupees are added in The Legend of Zelda Ocarina of Time.

Now, this works great. I’ve only run into one bug.

If I “pick up” too many of these “rupees” in a row, like before one has finished counting, then it does not fully update the number. It subtracts one or two (never more than two, I don’t believe, unless I add a lot of rupees with one call, like the “red rupees” which are worth 20, pictured below) from what the final count should be.

There’s my blueprint setup. “MaxNum” is just a maximum number I setup so it won’t count anymore if the “rupee amount” of the player is at max

Any idea what the problem could be?

Thanks!

Everything fires in a chain of events but if you’re using timers things can get messy. (Just putting that out there)

I’m not sure what your problem is but here are some things I would recommend which may improve our cause and even fix the problem.

Remove player reference variable.

Set collision type with only that of the players type. On overlap cast other actor to that of your player type. If cast successful use the result node to call Rupecounter.

Why is there a currentrupees variable. Do you do something with it later? If not get rid of it as this could create inconsistencies across rupees. If you do use it later then still get rid of it and create a reference to the blueprint holding the rupee counter(a player reference would be appropriate in this case) and get your rupee count from that reference.

Why is there a loop? Whatever thats doing, I almost guarantee that’s your problem.

Alright, I’ve done everything you stated (no, I did not use CurrentRupees, forgot to remove that from earlier versions of the BP). Everything is ruled out as the cause other than the loop. Macro is from here.

Thanks!

Do you want it to count up only for display? If so run that in a different blueprint. It’s definitely the loop giving you problems though.

Try something like this…(not tested but should work)

You just call AddRupees and it does the rest.

(I edited the image to clear the timer before setting RupeesUpdating to false)

While that works, it does not add up the amount by one, like I need it to do. It just skips up 20.

Appreciate it, but I need it to add up by one, which I believe was the purpose of the loop.

Here is a fast setup i made:

You need to create 3 variables:

  • counting and storing current amount of coins, call this “stored_coins” (integer)
  • updating visible counter so it matches amount of current coins call this “visible_coins” (integer)
  • boolean variable that is “Can_I_Play_Effect?” set it to True by default

Then on event tick:
check if “visible_coins” are different from “stored coins”, do nothing if they are same
If they are different:
check if “Can_I_Play_Effect?” is set to true
if its true set it to false, then play your effect, when finished, increase number of “visible_coins”, and set “Can_I_Play_Effect?” to True