Answer the question
In order to leave comments, you need to log in
How to set up an unusual health system?
We have a character whose initial xp=1, when he gets 50 points, his xp++, when he gets 100 points his xp++ again, and so on, I can't do it, I don't understand how to write the condition correctly. Note points are not scored equally, it is possible to go from 49 to 58.
Answer the question
In order to leave comments, you need to log in
Make an array of how much experience you need for a certain amount: 50 100 160 280 500 900 and so on.
Keep the total amount of experience, and when starting the scene / adding experience, recalculate the amount of hp
Pseudocode
function experienceUp(int amount)
{
if (player.exp < 50 <= player.exp + amount) {
player.health++
} else if (player.exp < 100 <= player.exp + amount) {
player.health++
}
player.exp += amount
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question