I made this script that should make my car drive, but i after i made a waitforseconds inside function Update it came with this message: Script error (Car): Update() can not be a coroutine.
can someone help me how to fix this?
Here is the script:
#pragma strict
var spin = 3;
var topSpeed = 20;
var speed : float = 0.0;
var slowDown = false;
function Update ()
{
if(Input.GetButton(“FORWARD”))
{
speed = speed+0.2;
slowDown = true;
transform.Translate(Vector3(0,0,speed) * Time.deltaTime);
}
if(speed > topSpeed)
{
speed = topSpeed;
}
if(slowDown == true)
{
transform.Translate(Vector3(0,0,speed) * Time.deltaTime);
yield WaitForSeconds(speed % 4);
transform.Translate(Vector3(0,0,0) * Time.deltaTime);
}
}