How do i make a variable not get past a number?
i ahve this script that should make a car accelerate, when i press “w” a variable will go from 0 and up. But there is a limit speed, and how do i make that?
so the variable want go further up that for example 20.?
Here is the script:
#pragma strict
var spin = 3;
var speed : float = 0.0;
function Update ()
{
if(Input.GetButton(“FORWARD”)
{
speed = speed+0.2;
transform.Translate(Vector3(0,0,speed) * Time.deltaTime);
}
}