Progress Bar Issue

Hello men, i have created these pics to explain the problem: there is a progress bar and it works normally for the first level. 10 points and each point the bar increment by one unit. So when i reach 10 points the bar is empty with new level. When i reach 11 points there is the great issue: Next level is composed by 20 points but the bar is at 55% at 11 points and the other 45% is composed by 19 points. Can you help me? Where is the mistake?

258820-9.png

258831-10.png

258832-11.png

Not entirely sure, but what stood out to me was the part after the branch in which you set CurrentXP to (CurrentXP - NeededXP).

It could also have something to do with your Add Grade function that I don’t believe you’ve attached.

Debugging this on your own is pretty simple, and learning how to do so would benefit you immensely in the future; you can start off by printing your values to the screen or watching them inside the blueprint itself at runtime, and make sure they make sense.

If you think about it, it makes sense; you have 11 points out of 20, which is just a bit over 50%.

According to the logic you described - your progress bar should display the difference between your current grade’s minimal and maximal points. If you walk through this logic - when you hit 10 points, you go up to the next grade, which has a minimum of 10 points and a maximum of 20 (thus, 10 points are 0%, 15 points are 50% and 20 points are 100%).

The exact mathematical approach depends on how you want to set it up exactly, but it shouldn’t be too complicated (I’d probably multiply Grade by something to get the relevant numbers).

the problem you have as mentioned by waxoff is that you are not setting the xp back to zero upon leveling. i would go with a four variable setup like you have but would structure it a bit differently, example below.

ok this may look a bit confusing but ill try to explain. first note i made this example modular so the levels will scale exponentially forever and is only limited by the level. so to start, on begin play i create the widget, add it to the viewport, then calculate the neededXp for the current level (you could just set the default value instead). then below that i have a custom event for adding score. the add score event first adds a point to the score variable via the increment int node (dark green ++), then add in however much xp you want ( again i used a increment to add 1), then we need to check to see if we leveled up via the is current xp => needed xp and a branch, if true we call the final custom event level up. the level up event increments the players level, then resets the current xp to 0, and calculates the needed xp for the new level. like i mentioned earlier i use a calculation for the xp so level 1 requires 10xp, lvl 2 20xp, lvl 3 40xp, etc.

course this is just an example and you may need to tweak it for your needs but it shows the basics of how you could get your system to work.

Thanks WaxOff for your help and of course thanks ThompsonN13… you saved me again the life. With your help i have realized this…

It finally works!!!