I wanted to make a ‘morale’ bar that indicates how much morale soldiers have.
I used this script, and linked the morale bar I wanted to change.
[SerializeField] private Player origin;
[SerializeField] private Text cookiesText;
[SerializeField] private Image moraleBar;
private float maxMorale = 1500f;
public float currentMorale;
private void Awake()
{
moraleBar = GetComponent<Image>();
}
private void Update()
{
currentMorale = origin.morale;
moraleBar.fillAmount = currentMorale / maxMorale;
Debug.Log(moraleBar.fillAmount);
}
However, the morale bar does not update in-game.
The console prints my fillAmount is working properly (between 0~1, depending on how much morale I have) so I guess there’s something wrong with the image reference.
So I double checked if I referred to any wrong images but no everything seems to be fine to me.
Please help T.T