Hi everyone,
I created a game where I have stamina and hence a stamina bar.
While playing in the editor, the stamina bar works fine and decreases every time I jump.
After building the game, the bar is shown but isn’t adjusting. The stamina is changed though.
Here is the stamina bar code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class LifeBar : MonoBehaviour
{
private const float MAX_HEALTH = 100f;
public float currentStamina = MAX_HEALTH;
private Image healthBar;
// Start is called before the first frame update
void Start()
{
healthBar = GetComponent<Image>();
}
// Update is called once per frame
void Update()
{
currentStamina = GameObject.Find("Dragon").GetComponent<DragonMovement>().stamina;
healthBar.fillAmount = currentStamina / MAX_HEALTH;
}
}