Slider for display progress towards next level

I wanted to have a slider to display the players progress towards the next level. I spent a good amount of time trying to figure out the equation for calculating progress towards next level. What I came up with seems to work, but if anyone has any suggestions to improve my code I would appreciate it! Im basically taking (current xp - the xp needed to achieve the current level) and dividing that by (required xp for the next level - the xp needed to achieve the current level). An example would be if the player had 34 points. The required xp for the current level was 30. The required xp for the next level is 40. So (34 - 30) / (40 - 30) = .4. I plan on touching up the look and placement of the progress bar, I just wanted to get it up and running.


Nicely done!

1 Like

Thank you!

1 Like

I’ve been scratching my head for a good hour trying to achieve this exact same thing, thank you so much for sharing!

1 Like

Glad it has helped you, hope your project is going well!

Nicely done. The math checks out, too. It’s the exact equation to normalise a value

(value - min) / (max - min)

Privacy & Terms