I have added the script to my .js file for the watercraft Smit Rotterdam, but now she floats well above the surface of the water, clearly I am missing something (possibly brains).
The contents of my js file are:-
//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(){
return {mass:7000000, hydro_h1:8, hydro_h2:20};
}
//invoked for each new instance of the vehicle
function init_vehicle(){
this.set_fps_camera_pos({x:0.0,y:24.6,z:20});
}
//invoked when engine starts or stops
function engine(start){
}
//invoked each frame to handle the inputs and animate the model
function update_frame(dt, engine, brake, steering){
var f = 4000000*(engine-brake);
this.extra_force({z:2,y:-70},{x:2000000*steering,y:f});
}
function update_frame (dt, engine, brake, steering, parking) {
// it is important that "parking" is inserted between the return variables
// of the update_frame function
var coeff = 50000;
// coeff determines the intensity of the force
// varies based on boat mass
// (try different values ...)
var vel = this.velocity (true);
this.extra_force ({z: 0, y: 0, z: 0},
{x: -coeff * vel.linear.x * parking, y: -coeff * vel.linear.y * parking});
}
any observation would be greatly appreciated.
Bob.