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?
asked Nov 07 '18 at 06:37 PM in Blueprint Scripting
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.
answered Nov 08 '18 at 02:39 AM
Follow this question
Once you sign in you will be able to subscribe for any updates here