Floor/Ceiling

GingerBGamesGingerBGames Member Posts: 390
edited November -1 in Working with GS (Mac)
Hello GS'ers,

I have a Mana Bar, and every time I use my powers, the Mana is decreased by X amount. I don't know how to put a floor limit on my Mana rule, such as when when it hits Zero, it doesn't fall below 0%. Also, when Mana isn't being used it recharges, so I need to to not go above 100%. I've tried a constrain, but that only put's it to 100 or 0. How can I accomplish this? Thank you.

Comments

  • simo103simo103 Member, PRO Posts: 1,331
    can you have is so when it is >99 it equals 100 and when it is <1 it equals 0?
  • gazjmgazjm Member Posts: 578
    I had a similar issue and solved it by having a rule which said

    If > than 100 change to 100

    And

    If < 0 change to 0.
  • spliketspliket Member Posts: 93
    i would just add extra rules to the behaviors you're using for changing the manna level in the first place.

    so, if you have a timer that's increasing manna all the time, i'd do this:

    if manna < 100
    timer every 1 second (or whatver)
    change attribute manna to manna+1 (or whatever).

    so, it's only adding manna if it's less than 100. once it gets to 100, it stops.

    do the same sorta thing for whatever is decreasing the manna.
  • GingerBGamesGingerBGames Member Posts: 390
    Thanks guys, Gazjm, that fixed it! Now I can finally move forward with the rest.
  • RHRH Member Posts: 1,079
    Or you could constrain it min(100,max(0,self.mana)

    I think that would work. Might be less performance draining as well.
  • GingerBGamesGingerBGames Member Posts: 390
    Thank you.
Sign In or Register to comment.