Increase Meter

I was watching a video that @tshirtbooth had on YouTube about adding a health bar to a game. I followed that video to actually add a skill meter to my game. In his video, his bar was shown to decrease. I was able to get my to increase instead. Only problem is that the meter goes beyond the area that I need to to stay in. When my actor collects a power up the meter increases. I have seen that once 7 power ups are grab the meter is full. How do I stop the meter from filling if the actor happens to grab more than 7? I'm thinking of some kind of constraint?

Comments

  • jamie_cjamie_c ImagineLabs.rocks Member, PRO Posts: 5,772

    If you have an attribute for the power ups, lets call it PowerUp, you would set up a rule like this:

    if PowerUp >= 7 then PowerUp = 7

    That should keep the power up equal to or less than 7.

  • GamingtilDawnGamingtilDawn Member Posts: 104

    @jamie_c A game level attribute?

    I made an integer game level attribute and started it at 0. Then in the power ups code had a rule:
    actor collides with tag characters

    change attribute game.skill to game.skill+13 (makes the meter increase in size)
    change attribute game.powerups to game.powerups+1

    another rule:
    attribute game.powerups >= 7

    change attribute game.powerups to 7

    that didnt stop it from increasing.

  • mhedgesmhedges Raised on VCS Member Posts: 634

    @GamingtilDawn , see if gets fixed if you invert the rules.

    I believe you may have it like this in your code:

    If collide then change attribute to skill+13 and powerups+1
    If powerups >= 7 then power ups =7

    Switch it around to:

    If powerups <7 then
    If collide then change attribute to skill+13 and powerups+1

    Let us know if that works!

  • jamie_cjamie_c ImagineLabs.rocks Member, PRO Posts: 5,772

    @GamingtilDawn, the attribute name and number I used were for a general idea, not specifically for use with your code. Now that you have said exactly how you are creating your powerup adjust what I said before to be like this:

    Use your game.skill attribute you have already created, no need to add the new game.powerups

    Add a Rule, probably in your meter actor:

    if game.skill >= 91 then game.skill = 91

    I used 91 since you are increasing the game skill by 13 each time 13*7 = 91 so after 7 skill increases it should not increase anymore.

  • GamingtilDawnGamingtilDawn Member Posts: 104

    Thank you @mhedges and @jamie_c! I got the meter to stop after 7 coins.

  • jamie_cjamie_c ImagineLabs.rocks Member, PRO Posts: 5,772

    sweet! :)

Sign In or Register to comment.