How do i put a limit on an attribute?!?

Game attribute: velocity 80 real
It starts off with 80. I have a timer which adds +5 to velocity every 2 seconds. I would like its maximum value to be 200. How do i do that?

Comments

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

    One way is to use a Rule that says something like this:

    Rule: If Velocity <= 200
    Change Attribute Velocity to Velocity + 5
    

    That would only add the 5 as long as Velocity is not above 200.

  • KillerPenguinStudiosKillerPenguinStudios Member Posts: 1,291

    +1 on @jamie_c‌'s answer

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    edited January 2015

    I think that would have to be Velocity ≤ 195 ;)

    Another way is the min() function which returns the smaller of two values:

    Change Attribute game.velocity to min(200,game.velocity+5)

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

    @tatiang‌

    I think that would have to be Velocity ≤ 195

    Oops. Yeah, I guess you're right, or Velocity < 200. :)

Sign In or Register to comment.