My health bars HealthBar.fillAmount doesnt change.tnx,i nead a help in fillamount :pls my HealthBar doesnt change. i dont know what to do.pls:)

using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;

public class PlayerHealth : MonoBehaviour
{

public int MaximumHealth;
public int CurrentHealth;
Image HealthBar;

void Start()
{
    
    CurrentHealth = MaximumHealth;
}

void Update()
{
    
    if (CurrentHealth <= 0)
    {
        SceneManager.LoadScene("Menu");
    }

    HealthBar.fillAmount = CurrentHealth / MaximumHealth;
}
public void DamageToPlayer(int damageToGive)
{
    CurrentHealth = CurrentHealth - damageToGive;
    
}

}

Yes… @dishant27

This is rather old, but I think the simple problem here is the use of integers. Both maximum and current health are ints, so the calculation for the division is also an int division, meaning it can only be 1 or 0. You’d need to either switch the type of the maximum and current to floats, or just cast them to float in the division op to force it to a float division instead.