Вот полный код
Код
public class CarControll : MonoBehaviour {
public WheelCollider[] frontCols;
public WheelCollider[] backCols;
public Transform[] dataFront;
public Transform[] dataBack;
public Transform[] Center;
public float maxSpeed = 233f;
private float sideSpeed = 30f;
public float brakeSpeed = 400;
void Start () {
}
void Update () {
float vAxis = Input.GetAxis ("Vertical");
float hAxis = Input.GetAxis ("Horizontal");
bool brakeButton = Input.GetButton ("Jump");
frontCols [0].motorTorque = vAxis * maxSpeed;
frontCols [1].motorTorque = vAxis * maxSpeed;
if (brakeButton) {
frontCols [0].brakeTorque = Mathf.Abs (frontCols [0].motorTorque) * brakeSpeed;
frontCols [1].brakeTorque = Mathf.Abs (frontCols [1].motorTorque) * brakeSpeed;
} else {
frontCols [0].brakeTorque = 0;
frontCols [1].brakeTorque = 0;
}
frontCols [0].steerAngle = hAxis * sideSpeed;
frontCols [1].steerAngle = hAxis * sideSpeed;
dataFront [0].Rotate (Vector3.right, -frontCols [0].rpm * Time.deltaTime);
dataFront [1].Rotate (Vector3.left, -frontCols [1].rpm * Time.deltaTime);
dataBack [0].Rotate(Vector3.right,-frontCols [0].rpm * Time.deltaTime);
dataBack [1].Rotate (Vector3.left,-frontCols [1].rpm * Time.deltaTime);
dataFront [0].localEulerAngles = new Vector3 (dataFront [0].localEulerAngles.x, hAxis*sideSpeed, dataFront [0].localEulerAngles.z);
dataFront [1].localEulerAngles = new Vector3 (dataFront [1].localEulerAngles.x, hAxis*sideSpeed, dataFront [1].localEulerAngles.z);
}
}