Race Lap Times

I have a racing game and at first I had a level mode where you beat a level and get the next level. Now I am implementing a season. For the levels I had a truck level in mind for the user truck to be at so I raced it over and over and got an average lap time for that track at that level. Then for the ai I changed the torque repeatedly until I got the lap times I wanted. This took a huge amount of time. Now for the season the user’s truck can be at any level and want the opponents times to be variable. I am looking for a way to set the torque of the truck off of a specified lap time. I have read several physics forums and Mat Buckland’s book physics chapter trying to use a physics formula but cannot get it to work.

So the question is I set a lap time of 12.00 seconds and need to make the truck get there at 12.00 seconds and would like to do so using physics for a realistic look. Wheels rotating, suspension etc.

I have a vehicle with wheel colliders and all wheel drive. I have a waypoint system to for guidance. If I set a torque and get the lap time the math adds up but I can’t backwards work it to figure out how to set the lap time and finish on time. Any help would be appreciated.

Thanks in advanced.

Maths heavy potentially - do up a table of value pairs and graph them (eg. torque is x axis, time is y axis) and you can work backwards from there… I can try and help if you post them but probably your most accurate answers would come from a maths forum.

Best case scenario they correlate fairly easily… worst case it may be maths magic…
eg.
http://math.stackexchange.com/questions/108566/writing-a-function-f-when-x-and-fx-are-known

The more points you have, the more accurate it will be; from memory you can do ‘best fit’ equations which mean you wont have the exact values but it will be a simpler equation.
At least once it is done and coded, the computer handles all the hard parts!

Update

Here is what I have so far. I get the distance of the race using the waypoints and vector3.distance. Then using that I use the time specified to find the acceleration = d2/t^2. Given the formula Force = massacceleration I have come close to what I am looking for, however still a little off. Any ideas would be great. I posted this part of my code below.

//Dist from start pos to first waypoint
distance += Vector3.Distance(transform.position, wayPoints[1].position);
//Total Distance
for(var w = 1; w < wayPoints.length-1;w++){
	distance += Vector3.Distance(wayPoints[w].position,wayPoints[w+1].position);
}
var d : float = distance*2;
var tSquared = wantedLapTime*wantedLapTime;
var a : float = d/tSquared;
torque = a * totalMass;
print(torque + " Final Torque");