hey gang! I have calculated my Player HP into 100 %.
I’m trying to translate this into decimals so 100% = 1 80% = 0.8 act
So i can use this number in Imagefill for a HP bar since Fillamount Only likes decimals
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class PlayerHealth : MonoBehaviour {
public float playerhealth;
public float MaximumPlayerHealth;
public float PlayerHealthPersentage;
public float PlayerFloatDecimal;
public Image PlayerHP;
public IndavidualScore Score;
public GameObject Missioncontroll;
public void Start (){
}
public void LateUpdate (){
// Calculate HP get 100%
PlayerHealthPersentage = playerhealth / MaximumPlayerHealth * 100;
//????????????????????_______________________________________________
//Set 100% to a decimal 100 = 1 80 = 0.8 act.....
= PlayerFloatDecimal; //????????????????????
//????????????????????_______________________________________________
if (Missioncontroll == null) {
Missioncontroll = GameObject.FindGameObjectWithTag("MissionControll");
Score = Missioncontroll.GetComponent<IndavidualScore> ();
}
PlayerHP.fillAmount = PlayerFloatDecimal; //Display HP BAR XD
if(playerhealth < 1){
Score.Lives -= 1;
}
}
}