Xp Bar Help.

Hello, I created a Xp bar and it works how i wanted but there is one bug i cannot seem to fix. So you start at level 1. The max Xp at level 1 is 1000. I have a function setup so i press “2” and i get 1200 Xp. And the Xp bar is setup to carry over whats left of the Xp to the new level. But for some reason when i reach max Xp the bar does not empty until i add more Xp then the Xp is carried over. So when i go in game and give myself 1,200 Xp it stays at level 1 1200/1000 until i add more Xp then it goes to level 2 200/2000. Does anyone know what is making it do this?. Ill post my blueprint and a video.

Part 1:

Part 2:


Hey FireZown,

I recreated my entire canvas exp system and converted it to UMG for 4.7. Below are all the functions used to create my system. I used a standard 3rd person template for this. This setup should greatly reduce the nodes you need to use to accomplish what you are after.

In the third person character blueprint.

These two functions should be pretty self explanatory.

In the experience bar widget. In this widget you will need the following variables, all of which are INTs but could be floats as well if you’d prefer:
Current EXP - 0
Overflow EXP - 0
Needed EXP - 500
Player Level - 1
Max Level - 10,000

This is simply my UI. It is two text blocks and a progress bar.
The white text, text block has a binding for its text as follows

The purple text, text block has a binding for its text as well.

The progress bar has a binding for its percent also.

You need to convert the integers here to floats to be able to return a non whole number value or rather your level’s percentage.

Here is the give experience function

The branch only returns a true statement when we have gained more experience than we needed to level and when we aren’t max level. This is the only time you need to call your level up function, since any other time, your current exp should just be lower than your needed experience.

Here is the level up function

I forgot to comment the last part of this but basically it just sets your current experience, after you’ve leveled, to whatever was left over from your previous amount. However if there was no overflow experience, due to hitting your level exactly, we simply reset the current experience to zero and start over.

Here is the final product of my example in action.

I really hope this helps out and sorry it took me so long to get around to it.

Thanks, This works great. But there is something in the method that is in my original method that i couldn’t work out. Let say i give large amounts of xp 500,000 for example. How would i have to use all the overflow xp and add it all up to the level it equals. Right now if i give that much xp it goes to level 2 fills the bar and then adds the overflow after each level. So with this setup 500k should take me right to about level 23 from level 1. (i Doubt ill ever give this much xp at once but better safe then sorry :))

That was a good question actually, and I was able to figure out a simple way to calculate it, see below.

Adding this into your level up function should fix it.

Let me know, I had never thought to check for that.

Edit: I set up the branch backwards, but basically if overflow EXP is less than what we require to level, process like we used to. If it’s greater though, re-run our overflow exp and repeat the process until overflow is not greater than needed experience.

Also just for fun, I tested the upper limits of how much experience to add with the F key and the game was okay using 100,000,000 experience in, but crashed due to infinite loop at 1,000,000,000 experience in.

Thanks, That is exactly what i needed!

(off topic how is your skill tree tutorial going ;))

super easy tutorial, hope this works