Hi I’m a beginner and was wondering how i could make a slider that decreases when a key is down. I am using this for a sprinting bar mechanic. I have something. Though it doesn’t decrease continually by 1, it only decreases once.
using UnityEngine;
using UnityEngine.UI;
public class shift : MonoBehaviour
{
public Slider slider;
void Update()
{
if(Input.GetKeyDown(KeyCode.LeftShift))
{
slider.value = slider.value - 1;
}
}
}