First in my game, i have “Booster” the problem is. If i make timer with “Time.delaTatime” with float, it also affect to my game timer. Since i changed timeScale.
So my Question is
“Can i make timer without touch my stamina code?”
Player will die after the timer reaches 0.00f // 30f start → 0f → player die
public void Booster()
{
isBoost = true;
}
void Update()
{
public float stamina = 10f, maxstamina = 10f;
public bool isBoost;
public GameObject staminaBar;
float myStamina = stamina / maxstamina;
if (isBoost)
{
Time.timeScale = 3f;
stamina -= Time.deltaTime;
staminaBar.transform.localScale = new Vector3 (myStamina, staminaBar.transform.localScale.y, staminaBar.transform.localScale.z);
if (stamina < 0)
{
stamina = 0.00f;
isBoost = false;
Time.timeScale = 1f;
}
}
else if (stamina < maxstamina)
{
stamina += Time.deltaTime;
staminaBar.transform.localScale = new Vector3 (myStamina, staminaBar.transform.localScale.y, staminaBar.transform.localScale.z);
}
}