Torque Valley: Driving, Drift and Crash Sandbox
README.md
aiDrivers
Checks the AI drivers' data, the path maths they plan by and the component's API:
- Personalities: five built-ins in order, each a complete table. They differ as described: the commuter is slower, brakes earlier, keeps a lane and leaves a bigger gap; the racer uses the full road; the drifter drifts with assists off; the tourist misses turns and stops; the aggressive driver tailgates.
extendcopies without touching the base, and an unknown base raises. - Paths:
resamplemakes even 2 m spacing on an open line (51 points over 100 m) and a splined loop (no repeated start).distancesmeasures loop and open lengths.normalspoint right of travel andoffsetslides lanes.curvaturesare ±1/R on circles (sign follows direction) and 0 on a line.nearestreturns the closest index and squared distance.speedProfilerespects the cornering limit √(latG·g/|k|),maxSpeedand the braking constraint, and ends an open route nearly stopped.racingLinestays within ±halfWidth, uses the width and lowers Σk² and peak curvature on the test track. - Track: 36 control points, a ~1.2 km closed centreline, an origin shift and alternating grid slots.
- AiDriver: on a script-controlled torqueCars hatchback (skipped without torqueCars):
setPersonalityswitches the driver and refuses unknown names,setPath/clearPathtake a route,laps()starts empty,stats().ratefollows the personality andstate()gives the full read-out.
It leaves alone actual driving (steering, pedals, overtaking, drifting, recovery, lap timing), which needs physics running in play, as well as the showcase scene and define(). define() registers a personality for the rest of the session, which a repeatable suite must not do. The test car is spawned far below the play area and despawned after the test.
Run it in edit mode:
return asset.resolve("aiDrivers", "testSuite"):run()