- Home /
Unity Health Math Problem
I'm making a platforming game, the character has a base amount of Health Points which is 50. I want to use the remaining percent amount of health to affect the grow size of a particle. I have already figured out how to modify the size growth of my particle, but I seem to be missing something very easy when it comes to my math.
I want to make it so, the lower the HP, the bigger the size of the particle will get with a maximum of 2,5.
Example using fictional informations: 10(%HP) (some math) = 2.5 90(%HP) (same math) = 0.8
Somehow I'm forgetting some fundamentals... Sorry if this is a dumb question, but I'm really puzzled by this.
If you have any idea which could help me out even though it is not the perfect answer, I won't mind.
Thanks in advance.
Wow thank you alot, I knew it wouldnt be anything hard. Have a nice day! :D
Answer by ian_sorbello · Aug 12, 2014 at 05:21 AM
float baseHP = 50.0f;
float maxSize = 2.5f;
float particleSize = Mathf.Lerp(maxSize, 0, actualHP / baseHP);
Your answer

Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Damage/Healing over time 1 Answer
Damage script 0 Answers
Death upon health = 0 2 Answers
can someone translate this to java I've tried a thousand time but couldn't do it 1 Answer