OK.. My game is working JUST ENOUGH to tweek physics on cars.
Here is what I got for the mustang after 20 minutes.
//vehicle script file
//see http://xtrac.outerra.com/index.fcgi/wiki/vehicle for example and documentation
//invoked only the first time the model is loaded, or upon reload
function init_chassis()
{
var wheelparam = {
radius: 0.35,
width: 0.15,
suspension_max: 0.10,
suspension_min: -0.15,
suspension_stiffness: 25.1,
damping_compression: 0.15,
damping_relaxation: 0.09,
slip: 0.60,
slip_lateral_coef: 1.5,
roll_influence: 0.1
};
var wheelparam_Rear = {
radius: 0.34,
width: 0.2,
suspension_max: 0.10,
suspension_min: -0.12,
suspension_stiffness: 18.4,
damping_compression: 0.12,
damping_relaxation: 0.08,
slip: 0.65,
slip_lateral_coef: 1.2,
roll_influence: 0.1
};
this.add_wheel('wheel_FR',wheelparam);
this.add_wheel('wheel_FL',wheelparam);
this.add_wheel('wheel_RR',wheelparam_Rear);
this.add_wheel('wheel_RL',wheelparam_Rear);
this.load_sound("Mustang start.ogg"); //startup
this.load_sound("Mustang idle.ogg"); //idle
this.load_sound("Mustang shutdown.ogg"); //off
this.add_sound_emitter("wheel_FL");
return {mass:1109, steering:2.0, steering_ecf:10000, centering: 1.5, centering_ecf: 10, com:{y:-0.10, x:0.0, z:-0.1}};
}
//invoked for each new instance of the vehicle
function init_vehicle(){
this.set_fps_camera_pos({y:-0.8, x:-0.32, z:0.8});
this.geom = this.get_geomob(0)
this.swheel = this.geom.get_joint("steering_wheel");
//invoked when engine starts or stops
this.snd = this.sound();
this.snd.set_ref_distance(0, 9.0);
this.started = 0;
}
function engine(start)
{
if(start) {
this.started=1;
this.snd.play(0, 0, false, false);
}
else {
this.started=0;
this.snd.play_sound(0, 2);
}
}
const EF = 12000.0;
const BF = 5000.0;
const maxkmh = 343;
const forceloss = EF / (0.2*maxkmh + 1);
//invoked each frame to handle the inputs and animate the model
function update_frame(dt, engine, brake, steering)
{
var kmh = this.speed()*3.6;
var redux = engine>=0 ? 0.2 : 0.6;
var esign = engine<0 ? -1 : 1;
engine = EF*Math.abs(engine);
var force = (esign>0) == (kmh>=0)
? engine/(redux*Math.abs(kmh) + 1)
: engine;
force -= forceloss;
force = Math.max(0.0, Math.min(force, engine));
engine = esign*force;
brake *= BF;
steering *= 0.75;
this.steer(-2, steering);
var steerAngle = steering *= 10.05;
this.geom.rotate_joint_orig(this.swheel, steerAngle, {x:0,y:-1,z:0});
this.wheel_force(-1, engine);
this.wheel_brake(-1, brake);
if(this.started==1 && !this.snd.is_playing(0)) {
this.started=2;
this.snd.play(0, 1, true, false);
}
else if(this.started==2) {
var pitch = Math.abs(kmh)/20.0;
var g = kmh>0 ? Math.floor(pitch) : 0;
var f = pitch - g;
f += 0.5*g;
this.snd.set_pitch(0, 0.75*f + 1.25);
}
this.animate_wheels();
}
Also forgot to mention. The wheels are animated backward.