So I have a script in my game for a plane. And I want to give it a speed boost, which I have. But I just can’t figure out time vairables. soooo here’s my script. I’ts apparently wrong, because the update() function can’t coroutine. Any Ideas how to fix this?
//speed variables
var speed = 5.0;
//boost variables
var boost = 1.0;
var strength = 1.0;
var boostLength = 5.0;
var boostReload = 10.0;
var hasBoost = false;
function Update () {
//Sets Constant speed for Plane * Boost
transform.Translate(0, 0, (Time.deltaTime * speed * strength));
if(Input.GetButtonDown("Boost")) {
if (hasBoost==false){
hasBoost = true;
strength +=boost;
//figure out time count down
yield WaitForSeconds(boostLength);
strength -=boost;
yield WaitForSeconds(boostReload);
hasBoost = false;
}
}
}