Hello, I've today decided to make an item box that creates an object that gives the player HP. The only problem I am having is that out of 100 health points my player has (the item gives 50 hp), it over extends over 100 hp which shouldn't be possible as of yet in my game. So yeah, how do I add a limit on my variables?
This is how I do it, but there might be a better way.
HP is greater than or equal to 100 - Set to 100
(This is a compare variable condition)
Let me know if you need more clarification.
Develop games in your browser. Powerful, performant & highly capable.
hp = min(100, hp + 50)
This is how I do it, but there might be a better way. HP is greater than or equal to 100 - Set to 100 (This is a compare variable condition) Let me know if you need more clarification.
It worked perfectly, thank you!