# How do I fix EXP bar and level up

0 favourites
• 6 posts
From the Asset Store
Custom Health Bar
\$3.50 USD
30% off
Custom animated Health Bar - check youtube video to make it yourself
• I have posted screenshots + GIF below. But basically, I have countEXP global variable, and it is set to 0 when the player levels up.

I have got when exp=>100, it'll level up to 2. I have done it all the way to level 3, and when at level 3, the countEXP starts from 0 and increases past 100, at which point it goes back to level 2.

Is there a way around this?

The events for the making of the exp bar:

gyazo.com/8b843efecc858b8164f19db7177a2acf

The events for the leveling up:

gyazo.com/b18c6700b73b8dee6d353c20fa726e1c

And the GIF of the problem:

gyazo.com/08f06b3b372c528797b691d4fb991035

(As you can see, level 2 to level 3 works fine. But of course because the countEXP gets set to 0 at start of new level(level3), it counts in 15 from 0, until it becomes =>100, which turns level 3 back to level 2.

• ## Try Construct 3

Develop games in your browser. Powerful, performant & highly capable.

Construct 3 users don't see these ads
• try adding a condition level number variable = 2

and for level 3 level number variable = 3

If you read your code out loud if your exp reaches to the number 200 then go to level 2. But you have no condition that says I am in level 3 when the exp reach to 200.

A friendly tip a machine is dumber then a rock. We have to input exact logic for construct to behave the way we want to.

• The easier thing to do would be make a simple function that sets a level variable base on experience level and let the experience variable go as high as it wants...

Ie. countEXP goes up as experience goes up and has no cap. The function compares countEXP and sets level variable based on countEXP value using a case type set up: countEXP <100 level=1; countEXP >100 but <200 level=2: countEXP >200 but <300 level=3: etc.

Then your main events can call this function anytime they need current level.

• The easier thing to do would be make a simple function that sets a level variable base on experience level and let the experience variable go as high as it wants...

Ie. countEXP goes up as experience goes up and has no cap. The function compares countEXP and sets level variable based on countEXP value using a case type set up: countEXP <100 level=1; countEXP >100 but <200 level=2: countEXP >200 but <300 level=3: etc.

Then your main events can call this function anytime they need current level.

I've got 2 questions.

First, how do you compare global variables with functions? I can only add/subtract/set variables. Unless you meant I add the compare as a condition, but then I would need to make tons of those functions for each level.

Second, wouldn't the compare "countEXP <100 level=1; countEXP >100 but <200 level=2: countEXP >200 but <300 level=3: etc" give me the same problem?

I mean each time the character levels up, the countEXP is set back to 0. So when they are level 3, and countEXP gets set back to 0, and they keep earning exp, they'll go eventually reach to the point where countEXP >100 but <200 is true, thus set back the level from 3 back to 2.

• try adding a condition level number variable = 2

and for level 3 level number variable = 3

If you read your code out loud if your exp reaches to the number 200 then go to level 2. But you have no condition that says I am in level 3 when the exp reach to 200.

A friendly tip a machine is dumber then a rock. We have to input exact logic for construct to behave the way we want to.

Wow that was simple XD Thanks so much!

Future reference for anyone:

gyazo.com/41c6009fbfa576dd24aae8b306d0790c

• 6 posts