Outerra forum
Anteworld - Outerra Game => Modding: Importer, Tools & Utilities => Topic started by: murkz on November 13, 2012, 03:12:48 am
-
Hi Outerra,
I am having some issues but progressing slowly :)
I have the test tank in, that is the good news.
It floats in the air, the wheels are about 1 meter off the ground, I have also included some images of the model in Max and the hierarchy, can you confirm these are correct.
(http://farm9.staticflickr.com/8203/8181480577_4ca4ca075d_b.jpg)
Floating above the terrain, I cant seem to enter the vehicle either. When I press enter the vehicle just rolls down hill.
(http://farm9.staticflickr.com/8205/8181515256_3bb74c8723_b.jpg)
(http://farm9.staticflickr.com/8202/8181515196_39cac81d2b_b.jpg)
-
There seems to be an error in your script - something about EF not defined, if I can decipher it right from the picture.
-
Ok the model is moving and I am driving it :) Thank you Outerra. The wheels are still not on the floor and do seem to react to the terrain undulations but the wheels are at least 750 mm above the terrain.
I also seem to have the gun facing the wrong way :D should be easy enough to fix...
I copied in the config file for the BMW and the error was gone.
-
Did you adjust the wheel size (radius) in the init_chassis, before adding the wheels?
-
Ok it is now on the ground, it was my noob error. I had the wheel circumference set to 1 meter instead of .5
Thank you cameni for all your help :)
(http://farm9.staticflickr.com/8062/8181591084_4b84c86d58_b.jpg)
And here she is, a real thing of beauty :-*
A small update 8 wheels added:
(http://farm9.staticflickr.com/8346/8181935758_11ce192444_b.jpg)
-
How does it turn? Can you set it up to actually turn like a tank yet?
-
How does it turn? Can you set it up to actually turn like a tank yet?
Unfortunately it steers like a car at the moment but I have pushed on with another of my vehicles :)
(http://farm9.staticflickr.com/8338/8182712856_72005cffb1_b.jpg)
(http://farm9.staticflickr.com/8338/8182711764_9a3df97695_b.jpg)
I have a few issues with this as well.
1, The wheels that touch the ground rotate and the higher ones only when they touch the ground. They should turn all the time but I don't know how.
2. I don't know how to make the steering wheel turn
3. What does Outerra have planned for tracks? There are several options that I know of :)
-
I guess it could turn like a tank, needs to change the sign of engine force applied to the wheels to be different on each side when turning, or brake one side.
Only the wheels that touch the ground are rotating with animate_wheels() currently, but you could rotate it manually via geomob (http://xtrac.outerra.com/index.fcgi/wiki/geomob). The same for the steering wheel: first call get_geomob(0) to get the geometry object, then get the joint of the steering wheel and call one of the rotate methods on it.
function init_vehicle() {
this.geom = this.get_geomob(0);
this.swheel = this.geom.get_joint("your steering wheel node");
}
function update_frame(...){
...
this.geom.rotate_joint_orig(this.swheel, angle, {x:0,y:0,z:1});
}
This assumes you have the steering wheel as an object with rotation axis aligned with z, change if needed.
Once there's a specific track physics, it will solve the wheel rotation problem as well as other things. But I didn't think it through yet completely.
-
I guess it could turn like a tank, needs to change the sign of engine force applied to the wheels to be different on each side when turning, or brake one side.
So how would I accomplish this please Cameni and can we use one key for each tracks brake i.e:
W forward, Q left track brake, E right track brake.
-
This look good Murkz, so we get a Panzer simulator with Outerra :)
-
You could try something like conditioning it based on the steering value. For negative steering value, brake wheels on one side, for positive the other.
For better (custom) control we first need to expose general inputs in the script, so that you can bind whatever you need there. Right now you are getting only the engine power (-1..1), brakes (0..1) and steering (-1..1) axes.
Btw I'm going to move these posts to the importer thread, they contain info that will be useful for others and easier to find there.
-
When I would code steering for tanks in garrys mod I would do so with WASD keys and it looked like this..
FB Controller...
10=W or Forward
5=S or Reverse
LR Controller...
4=A or left
6=D or right
Tl is Track Left, Tr is Track Right output
Wl is weld left and Wr is weld right (In game to stop the tracks from moving at all IE drag)
WB is weld both or to simulate a locking differential between the two so you drive strait.
FB == 10 -> Tl=1 Tr=1 Wl=0 Wr=0 WB=1;
FB == 5 -> Tl=-1 Tr=-1 Wl=0 Wr=0 WB=1;
LR == 6 -> Tr=8 Tl=-8 Wl=0 Wr=0 WB=0;
LR == 4 -> Tr=-8 Tl=8 Wl=0 Wr=0 WB=0;
FB==10 & LR==6 -> Tr=4 Tl=-2 Wl=0;
FB==10 & LR==4 -> Tl=4 Tr=-2 Wr=0;
FB==5 & LR==6 -> Tl=-4 Tr=-2 Wr=0;
FB==5 & LR==4 -> Tr=-4 Tl=-2 Wl=0;
FB == 0 & LR == 0 -> Wl=1 Wr=1 Tl=0 Tr=0 WB=1;
You would do something similar to to control a tank with a 4 way controller.
-
Outerra track vehicle import test (http://www.youtube.com/watch?v=co262Xz7VqY#ws)
A small youtube video.
-
I want tracks so bad now.
-
Oh, a panzer simulator in outerra? That would be a dream! I already have lots of ideas.
-
Only the wheels that touch the ground are rotating with animate_wheels() currently, but you could rotate it manually via geomob (http://xtrac.outerra.com/index.fcgi/wiki/geomob). The same for the steering wheel: first call get_geomob(0) to get the geometry object, then get the joint of the steering wheel and call one of the rotate methods on it.
function init_vehicle() {
this.geom = this.get_geomob(0);
this.swheel = this.geom.get_joint("your steering wheel node");
}
function update_frame(...){
...
this.geom.rotate_joint_orig(this.swheel, angle, {x:0,y:0,z:1});
}
This assumes you have the steering wheel as an object with rotation axis aligned with z, change if needed.
Hi Cameni,
I have tried the code but get a unexpected token error, line 110
I have no clue what that means :) as I am a scripting noob...
-
Please post what's in your script on line 110 (+- a few lines around).
-
Hello guys ... i am stuck on scripting a driving tank.
I can move foward and backward but turning is a book with seven seals. I am not a real pro on scripting so I could really need some help.
//vehicle script file
//see http://xtrac.outerra.com/index.fcgi/wiki/vehicle (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.25,
width: 0.2,
suspension_max: 0.2,
suspension_min: -0.2,
suspension_stiffness: 3.0,
damping_compression: 0.05,
damping_relaxation: 0.2,
slip: 0.8,
roll_influence: 0.1
};
this.add_wheel('wl_01',wheelparam);
this.add_wheel('wl_02',wheelparam);
this.add_wheel('wl_03',wheelparam);
this.add_wheel('wl_04',wheelparam);
this.add_wheel('wl_05',wheelparam);
this.add_wheel('wl_06',wheelparam);
this.add_wheel('wl_07',wheelparam);
this.add_wheel('wl_08',wheelparam);
this.add_wheel('wl_09',wheelparam);
this.add_wheel('wr_01',wheelparam);
this.add_wheel('wr_02',wheelparam);
this.add_wheel('wr_03',wheelparam);
this.add_wheel('wr_04',wheelparam);
this.add_wheel('wr_05',wheelparam);
this.add_wheel('wr_06',wheelparam);
this.add_wheel('wr_07',wheelparam);
this.add_wheel('wr_08',wheelparam);
this.add_wheel('wr_09',wheelparam);
return {mass:71700, com:{y:-0.55},};
}
//invoked for each new instance of the vehicle
function init_vehicle(){
}
//invoked when engine starts or stops
function engine(start){
}
//invoked each frame to handle the inputs and animate the model
const EF = 7000.0;
const BF = 40000.0;
const maxkmh = 34;
const forceloss = EF / (0.2*maxkmh + 1);
function update_frame(dt, engine, brake, steering){
var kmh = this.speed()*3.6;
//reduce engine force with speed (hack)
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;
steering *=0.6;
this.wheel_force(0, engine);
this.wheel_force(1, engine);
this.wheel_force(2, engine);
this.wheel_force(3, engine);
this.wheel_force(4, engine);
this.wheel_force(5, engine);
this.wheel_force(6, engine);
this.wheel_force(7, engine);
this.wheel_force(8, engine);
this.wheel_force(9, engine);
this.wheel_force(10, engine);
this.wheel_force(11, engine);
this.wheel_force(12, engine);
this.wheel_force(13, engine);
this.wheel_force(14, engine);
this.wheel_force(15, engine);
this.wheel_force(16, engine);
this.wheel_force(17, engine);
brake *= BF;
this.wheel_brake(-1, brake);
this.animate_wheels();
}
-
Here I've got one tank script with turning, done for another user (murkz), it may be helpful for you:
//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.46,
width: 0.20,
suspension_max: 0.2,
suspension_min: -0.35,
//ride height
suspension_stiffness: 3.0,
damping_compression: 0.2,
damping_relaxation: 0.12,
slip: 0.5,
roll_influence: 0.1
//rotation: -1
};
this.add_wheel('wheel1', wheelparam);
this.add_wheel('wheel2', wheelparam);
this.add_wheel('wheel3', wheelparam);
this.add_wheel('wheel4', wheelparam);
this.add_wheel('wheel5', wheelparam);
this.add_wheel('wheel6', wheelparam);
this.add_wheel('wheel7', wheelparam);
this.add_wheel('wheel8', wheelparam);
this.add_wheel('wheel9', wheelparam);
this.add_wheel('wheel10', wheelparam);
this.add_wheel('wheel11', wheelparam);
this.add_wheel('wheel12', wheelparam);
this.add_wheel('wheel13', wheelparam);
this.add_wheel('wheel14', wheelparam);
this.add_wheel('wheel15', wheelparam);
this.add_wheel('wheel16', wheelparam);
return {mass:7530, steering:2.0, steering_ecf:60, centering: 10, centering_ecf:20};
}
//invoked for each new instance of the vehicle
function init_vehicle(){
this.set_fps_camera_pos({x:-0.33,y:2.00,z:2.10});
}
//invoked when engine starts or stops
function engine(start){
}
const EF = 10000.0;
const BF = 4000.0;
const maxkmh = 50;
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;
//reduce engine force with speed (hack)
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;
var el = steering>0 ? 0 : engine;
var er = steering<0 ? 0 : engine;
this.wheel_force(0, el);
this.wheel_force(2, el);
this.wheel_force(4, el);
this.wheel_force(6, el);
this.wheel_force(8, el);
this.wheel_force(10, el);
this.wheel_force(12, el);
this.wheel_force(14, el);
this.wheel_force(1, er);
this.wheel_force(3, er);
this.wheel_force(5, er);
this.wheel_force(7, er);
this.wheel_force(9, er);
this.wheel_force(11, er);
this.wheel_force(13, er);
this.wheel_force(15, er);
brake *= BF;
var bl = steering>0 ? BF*steering : 0;
var br = steering<0 ? -BF*steering : 0;
bl += brake;
br += brake;
this.wheel_brake(0, bl);
this.wheel_brake(2, bl);
this.wheel_brake(4, bl);
this.wheel_brake(6, bl);
this.wheel_brake(8, bl);
this.wheel_brake(10, bl);
this.wheel_brake(12, bl);
this.wheel_brake(14, bl);
this.wheel_brake(1, br);
this.wheel_brake(3, br);
this.wheel_brake(5, br);
this.wheel_brake(7, br);
this.wheel_brake(9, br);
this.wheel_brake(11, br);
this.wheel_brake(13, br);
this.wheel_brake(15, br);
this.animate_wheels();
}
-
thank you very much ... I gotta eat now and then I will get through this step by step to understand what is happening there. Appreciate your help very much!
-
After some days spending with the band and work I got the time to try out the script.
Indeed it works .... the wheels move now in the correct way if I want to turn and it turns. But verrrrryyyy slow. I moved up const EF up to 40000 but still it turns slow. I played around with the mass and with the wheelparam but nothing helps ... did I make a mistake in 3D Max??!?!
-
I believe the problem is in the missing separation between lateral and longitudinal friction. There's just some hardwired internal coefficient, roughly set for normal tires, but for tank tracks it must be a much higher difference, easier for tracks to slide sideways. I'm going to expose the coefficient in the configuration somewhere.
-
So he needs to lower his slip values. When I coded tanks in garrys mod I made it so static turns were granted more power than just going strait or turning while moving forward. I am sure you could hack that in there.
-
I tried this allready ^^ was funny to see a 70 tons Jagdtiger slipping around like a block of ice. You cant even brake if you want :o