Calculating Health from Health Ratio

Learn to properly calculate actual health values from Actor.getHealthRatio() using the correct formula.

1 steps
Progress1 / 1 steps
1

Understanding Health Ratio

Step 1 of 1

Objective

Learn how health ratio works and how to calculate actual HP.

Explanation

Actor.getHealthRatio() returns a value from 0-255 representing health percentage. - 255 = 100% health - 0 = 0% health To get actual HP, you need: - Health ratio (0-255) - Max HP (from Actor.getMaxHealth() or Skill.HITPOINTS) Formula: currentHP = (healthRatio * maxHP) / 255

Your Code

java
AdvertisementSet slotId on <AdUnit /> to show ads.
← Back to Tutorials

🎉 Congratulations! You've completed this tutorial!