how i can i implement a timer before max boost

Heya i was wondering how to implement a timer into the script i attached am not that good of a scripter so if u can point me in the right direction or help me.

by time i mean a delay before maxboost is max for an example when the car goes above 3500 rpm i want it to engage the turbo but not with max boost i want a delay on the part so it takes maybe 0.5 seconds or something like that before max boost is reached.

also if anyone knows how to attach this to a GUI later that would be awesome.

and also if anyone can help me optimize the script that would be helpful.

// Johan

using UnityEngine;
using System.Collections;

public class Turbo : MonoBehaviour {

public float minBoost;
public float maxBoost;
public float boost;

Drivetrain drive;
 
// Use this for initialization
void Start () 
{
	drive = GetComponent<Drivetrain>();
}

// Update is called once per frame
void Update () 
{
	if (drive.rpm > 3500f)
	{
		if (maxBoost > minBoost)
		{
			drive.powerMultiplier = 2f;
			boost = maxBoost;
		}
	}
	else
	{
		if (maxBoost > minBoost)
		{
			drive.powerMultiplier = 1f;
			boost = minBoost;
		}
	}
}

}

If you want one instant value change after a short wait, you can just use Invoke()

If you want a gradual change in value over time, you’ll need something a bit more complex – for example, you could run a function every frame that increases the boost by a small amount, until it reaches a maximum.

This would be a pretty simple example, which doesn’t actually do any boosting but does demonstrate the above:

void Update()
{
    boostValue = Mathf.Min(boostValue + Time.deltaTime * boostPerSecond, maxBoostValue);
}