Evenly grow progress bar in normalised range

Hi,

I’m trying to set a progress bar when I upgrade an item but I need it to increment evenly.

I add an element to an array and set the upgrade value. The problem is the big jump at the end

Currently the bar jumps like this

But I’m looking for each segment to be split evenly

Say if I had 12 indexes in the array, I’m hoping for this to work evenly whatver the index amount is like below

Try map in range instead.

As input you put 0-200 , as output 0…1 for progress bar.

NVM i got what you want to do (but i use map in range anyways):

  • lets say you have last index of 5, so you have 6 segments
  • so you have: per_segment_delta = max_input_range / (last_index+1)
  • output range is then from: current_index * per_segment_delta to: (current_index+1) * per_segment_delta
  • and input range is values from array from current value to next segment value

Sorry, could you clarify on this? I tried a few ways using clamped map in range, but can’t get anything to work properly

Here’s the effect you’re going for:

output

General Strategy

  1. Calculate the percentage of the bar that should go to each level
  2. Calculate how many “whole” levels the player is above
  3. Calculate the player’s progress from their current level to the next level, add to step 2
  4. Multiply all that by the percentage of the bar that should go to each level.

That’ll be your progress bar value.

Blueprint Code

Here’s how I’d handle something like that:

I created a second helper function to grab the index of the array based on the player’s input value:

Hope this helps!

This is sort of what I have already, i’m trying to evenly grow them no matter what the next value is.
It could start at 100 then 150, 3000, 3100, 20000 if I wanted. It shouldn’t matter if the values are really weird and have high jumps

You could consider the actual level number instead of the value in it.
because you mentioned that the value in the array matters little.
so each section in the progress bar represents a level.
just calculate the array length.ignore the values in it.

index +1/array length =percentage

not sure if the +1 is needed (my weakness…always forgot,you might need to try it twice for yourself)
and you might need to turn them into floats before the division.

Oh - I think the answer I posted may still be what you want.

I should have specified - I used the same values you provided for the thresholds in the original post: 100, 120, 130, 140, 150, 200. That’s why the bar goes up only a little between each increment between 150-120.

This solution will work with whatever weird or high jumps you have. The blueprintUE link allows you to copy and paste the code directly into your blueprints if you’d like to give it a try!