Simple math problem with xp bar and percentage are not matching togheter..

I have some xp leveling system which works well as it is but im not happy how the system works and is pretty basic. So i am trying to change it a little so that it fits what i’m aiming to achieve. For now the xp system works like this - at lvl 1 im 0% xp and next level is 250 so i can see 0/250 xp for the next level. When i reach 250/250 the xp bar resets to 0 and the xp text as well. And when the next level starts it is then lets say 300 xp needed, so then it shows me lvl 2 - 0/300… But i want this to work differently. I want that the total xp amount is aways continusly counted and not get resettet back to zero. In the same example at lvl 2 when i reach reach 250xp it should display 250/550 (lvl 1 was 250 xp and lvl 2 is 300xp so this should increase accordingly rather then reset to 0) Awso the earned xp should awso never reset to 0 but continue. I dont want for lvl 10 something like 0/5000xp but it should count all the previous xp gained from the beginning and be like at lvl 10 something maybe 9000/16000xp… The difference is still the same for the next lvl i need 5000 xp. Thats all

So far i managed to display the current xp and the max xp just as i wanted but the problem i now have is that the xp bar do not reset to 0 after leveling up :frowning:

Here is how this looks like and it has to do with the current xp amount divided with the max xp…

I try to set the current xp and max xp after the “increase level” function but the result is still the same and the bar do not reset back to zero… Not sure what else i can try

How close is this:

Yeah like this how did you make it ? looks nice just what i need :smile:

hmm i see some small problem tough not sure why it shows at the start xp 16/18 when it reaches 18 xp and the next level starts it shows for a split secound 17/35. Should the next level display starting at 19/35 xp ?

I do not reset the progress bar, I change the range it operates in.



hmm i see some small problem tough not sure why it shows at the start xp 16/18

Just a recording loop. I am really slow with pushing the buttons. Did not test it for long, seems to add up - fingers crossed!

when it reaches 18 xp and the next level starts it shows for a split secound 17/35. Should the next level display starting at 19/35 xp ?

I’d say no, if you have 18XP now and level up, the new bar should have a range of 18-35. There’s a chance I misunderstood, ofc.

Ty i will try it out in a min…

Yeah true my bad when it reaches exactly 18xp then lvl up should happen and it will be 18/35 still 17/35 should not happen tough

bandicam 2023-07-04 23-49-38-695

and then

bandicam 2023-07-04 23-49-46-161

1 Like

pff, you’re right. I’ll have a look tomorrow. Hopefully it’s a tweak to the order of operations.


It’s this:

Totally deserved; serves me well for using float in place of an int. Updated the image and snippet. Ideally, these all should be integers.

1 Like

i have another idea to roll back the xp and max xp to display 0/250 then it resets the percantage bar then next level 0/300 and so on. Then i will create extra xp and max xp only for the text so it will be like 250/550 xp on the text but on the percentage bar it will be extra 0/300 in the exact same moment. Both will be separated from each other and percentage bar will reset. even if i have 0/5000 xp set on the percentage bar should equal to the text xp maybe 9000/14000xp at this moment. i hope it works …

It almost works. If i separate the progress bar xp and the text and have double variables extra for the text and the percentage bar…

Its really close now progress bar resets and the current xp awso continue and do not reset to 0. But i cant make the current max xp show up correctly. i acctually only need to be able to add max xp (from older lvl 1) + the current max xp when lvl 2 starts then it will equal to the max xp in total or so… but its really close as it seems

Hi, i couldn’t implement your stuff i got errors on other BP’s so i stick with my idea to split the percentage bar with the xp text. Basicly the bar resets as it normally would but the xp text is changed and it shows the total amount of xp and not resetting it back… Well i finally make this one work but a small problem pop up. I cant set the xp which are all integer to multiply by 1.2… I can only set 2x the xp (increase total xp amount per level) which is way too much. I try to change the xp integer to float but it aways break the calculation by few xp… The first levels work but then after 3-4 levels the xp and the actual xp fall behind…

Let me show you how this looks like… In the start i showcase how it is perfectly working when i got the xp multiplier by x2… Then later you see what happens when i try to change the x2 to x1.2… I tried to add 20% or math expressions but aways something dont work and the xp calculation break. Changing the max xp integer to float awso break the calculations for some reason :(( Maybe you have an idea whats going on and how i can change the xp per level to be somewhere around 1.2 times xp increase per level and not 2x ?

Yo i made it! I finally found out why the xp breaks after a few level up’s.

Its because the percentage bar knows only the difference between the max xp and current xp so it aways just reset back to 0 after max xp is reached. But the text is showing the real current xp which never gets to 0 and the max xp which awso never goes to the amount of xp needed to level up between levels. So when i do lets say +100xp increase and my max xp on the percentage bar is like only 10 xp off to trigger a reset - i need to calculate that i not only lvl up with this 100xp but added new +90 xp to the next level.

For that all I needed to do was to add this node and now everything works :joy:

Here is the end result :sunglasses:

So again to summerize it when i kill lets say a boss that gives 200xp but i only need 5xp to reach the next level, now i am not losing 195xp just because i reach the 5xp with it and bar just resets back to 0. Now it moves the rest xp acquired to the next level so i then have level up and +195xp made in the next level. Just what i wanted but even more important was to show the total amount of xp acquired in the game and not aways to fall back to 0xp. It’s just way way better now. Thx for the help

Do you still need help?

1 Like

No not anymore. I just solve the last piece i was missing. The ceil node on the max xp equation was the problem… I remove it from there and instead i used ceil only on the text. As it seems the max xp still counts the xp with float numbers that doesnt matter as long as i display the text as full numbers with the ceil node. So i dont get anymore any difference of 1xp or more… even at lvl 40 if i add the last xp it aways level up so i think thats good now for sure and thx :wave:

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.