Collectables "counting up"

I have collectables already done in BP, but the score increases immediately as opposed to gradually.

For example, my score is 45 and I collect a gem which is worth 5 points and it immediately increases to 50. But I want it to count up to 46, 47…all the way to 50. Here’s an example of what I’m looking for - Spyro: Year of the Dragon - 100% - Sunny Villa - Part 1 - YouTube

What would I need to add so it counts up? :slight_smile:

Use a “For Loop” that has your 5 as the amount to loop through and do a ++ on the value with a delay so that you can see it as it updates.

An (IMO) better way is to use an FInterpTo node, coupled with a Round node, in your UMG blueprint.

That way, if you have 45 gems and collect a 5 gem, it will increase to 50 right away. The GUI will “roll up” to that number for visual reasons by Interpolating from 45 to 50, but the internal score count will be correct instantly. This not only makes it easier to tweak the increase rate (just adjust the InterpTo speed), but also avoids edge cases like the player dying while the number is rolling up or something which could break the count loop.

The 5-point gem increases the score hy 5 points, the gradual roll-up is a purely aesthetic flair, I would take care not to make those aesthetic actions happen using core gameplay logic if it’s reasonably possible.

My $0.02

Not sure how to use it correctly with this current set-up:

You wouldn’t do it in the Gem BP, you’d do it in the HUD BP. Wherever you’re displaying the gen count for the player.

Somewhere in there, you’re getting the ACTUAL value of the Gem count and displaying it as text; I’m saying that, instead of displaying that number, you feed it to an FInterpTo node setup (Gem count as target, a placeholder variable like DisplayGemCount as current, FInterpTo’s output Setting DisplayGemCount, and then reading DisplayGemCount > floor node to make an Int which you acually display as text).

1 Like

Yeah I agree thats a better method, I had said fInterp on there originally but haven’t played around with it much so figured I would advise a simple solution, your’s is definitely more future proof though.

I tried it and the text seems to display “False”? What am I doing wrong?

Because the node you are passing across is a boolean variable, see the red coming out of your > node. You want to get the actual value from your fInterp

I tried to do every step that you said previously, but now the HUD doesn’t increase at all?

Your “Set” node for HUDGem has no execution path wired to it, it needs to be executed to increment the count.

Tried this, and the HUD does interpolate. But it’s very erratic and I can’t get it as smooth as the Spyro games’ collectables for some reason.

Tried tweaking the Delta Time and Interp Speed, but either it’s the same effect as before, it doesn’t interp to the target value and/or it interps too quickly to the target value.

You need to connect world delta seconds to delta time. It can’t be a constant number.

Thank you :slight_smile:

But there’s still a problem with Interp Speed. When I collect a gem with a 1 value, the HUD doesn’t update. But when I collect a higher value gem, it interps fine although it’s a bit too fast.

Increasing it makes it the same effect as before.

Maybe try replacing your FInterpTo node with an FInterpToConstant. They’ll connect up the same, but an FInterpTo adjusts its interp speed based on the distance it has to cover, while an FInterpToConstant will always interpolate at the same rate regardless of the distance (meaning a larger change in values will take a longer time to roll up to).

1 Like

I do this with a delay…It’s easier to control the speed then as it’s just a number I’m setting…


Every .0625 the number counts up/down until it’s even…then it stops…If I don’t like the speed I change the delay number…easy enough…

This of course also works, but I can think of some situations where it might be a problem (say you reach the end of a level or collect a new gem before the current one is done counting up). IMHO it’s better to treat a 5-gem as an instantaneous addition of 5 to the score and treat the rolling-up numbers as visual flair, though obviously if it doesn’t pose an issue to you then you can do it the manual-addition way.

The variables have confusing names but “Desired Yen” is what I save out to the save file when the level ends or when I save game…so Really “desired yen” is current yen and the “current yen” should be named “Yen Hud Counter” or something…but I’m too lazy to change them…but it does avoid the end of level issue and if you add more yen (or even subtract) before the variables are even it just keeps going until it is even so that’s luckily not an issue either…

but on a much more serious note When are you showing off more of your game RhythmScript…I’ve been salivating over the one short video you shared with someone on this forum like a year ago and that’s all I’ve seen…Must see more…it’s got to be awesome by now…

Sorry for getting off topic but yeah you’ve lots o’ options to get a counting up Hud working…