I’m already here… I solved the boost on Input.GetKey but now i would like to fit a reload timer before the boost is full again…
Here is some code:
// MANUAL BOOST
if (control && boostKey == true) {
if (manualBoostTimer == 0.0F || lastBoostTime > 0.0F && lastBoostTime < 5.0F) {
manualBoost = true;
maxSpeed = GameManager.Instance.GetBoost ();
accel = 20.0F;
}
} else {
lastBoostTime = manualBoostTimer;
manualBoost = false;
}
if (manualBoost && !stopBoost) {
manualBoostTimer += Time.deltaTime;
lastBoostTime = manualBoostTimer;
if (lastBoostTime >= 5.0F) {
manualBoost = false;
manualBoostTimer = 0.0F;
lastBoostTime = 0.0F;
stopBoost = true;
}
}
if (stopBoost) {
manualBoostReloadTimer -= Time.deltaTime;
if (manualBoostReloadTimer <= 0.0F) {
stopBoost = false;
manualBoostReloadTimer = 10.0F;
}
}
This solution has a big bug: the boost is active even when is reloading.
Do someone can correct it?