Limiting a property

I’m trying to make sure that a property named “Health” does not exceed the value of another property named “MaxHealth”.

In the above screenshot you can see that the property “Health” increases whenever I press the Spacebar.
I can also make the property decrease with Backspace (these will both be replaced with “Message” sensors later on).
What I tried to do is connect the keyboard sensor with a property sensor and make the value of “Health” increase only if I press the keyboard AND the value of “Health” is less than the value of “MaxHealth”.
Unfortunately, this does nothing, even if I decrease the value of “Health” below “MaxHealth”.
After fiddling with a bunch of other ideas and coming up dry, I’ve run out of ideas and call upon the powers of the community again ^^;

The property brick needs a value, so you need to manually set the max health.

use an expression brick.
keyboard -> expression (health < maxHealth) -> other stuff

Ooooooooooohhhhh… So THAT’S what the “Expression” controller does…
I see this coming in handy in some other places…
Hey, thanks a lot ^^

1 Like