// Update is called with fixed time step void FixedUpdate() { drivetrain.ComputeVehicleMovingForce((float)v, vehicleWheelRadius, controlsThrottle, controlsShiftUp, controlsShiftDown); resistance.ComputeDragForce(v); resistance.ComputeRollingFrictionForce(v, drivetrain.GetVehicleMovingForce()); a = (drivetrain.GetVehicleMovingForce() + resistance.GetDragForce() + resistance.GetRollingFrictionForce()) / vehicleMass; dv = a * Time.fixedDeltaTime; v = v + dv; v = Mathf.Clamp((float)v, 0, (float)drivetrain.GetMaxVelocityAtCurrentGear(vehicleWheelRadius)); ds = v * Time.fixedDeltaTime; float x = vehicleRoot.position.x; float y = vehicleRoot.position.y; float z = vehicleRoot.position.z; vehicleRoot.position = new Vector3(x, y, (float)(z - ds)); currentRPM = (int)drivetrain.GetCurrentRpm(); currentSpeedKMH = (int)Mathf.Round((float)(v * 3.6)); currentGearActual = drivetrain.GetCurrentGear(); currentDistance += ds; }