Hey I know this has been answered many times but none of them help me so… I’m asking again
I’m using the UI component in Unity and i have a health bar that works but I can’t get my stamina bar to work I have a slider and i want it to go down when the left shift is pressed but for my health bar it allows me to select which bar i want to use and on my stamina it doesn’t any help is appreciated I’m writing in C# The code is still not finished because I want to finish this problem before i move on
#pragma strict
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class MovementScript : MonoBehaviour {
public Slider StaminaBarSlider; //reference for slider
private bool CanRun = true; //flag to see if you can run
void Start(){
CanRun = true; //disable GameOver text on start
}
//Check if player enters/stays on the fire
void Update(){
if(Input.GetButton("LeftShift") && StaminaBarSlider.value>0){
StaminaBarSlider.value -=.010f; //reduce health
}
else{
CanRun = false
}
if(StaminaBarSlider.value == 0){
}
}
}