Outerra forum
Anteworld - Outerra Game => Modding: Importer, Tools & Utilities => JavaScript development => Topic started by: zzz on September 19, 2015, 06:41:18 pm
-
It seems the axis_integrator function no longer exists, which is a bit worrying as it's key to turret functionality :-[
-
Axis integrator was just a piece of js injected into vehicle scripts. To use it, simply include this code:
function axis_integrator(maxspeed,maxaccel,clamp_min,clamp_max){
this.mac = maxaccel ? maxaccel : 1.0;
this.msp = maxspeed;
this.speed = 0;
this.value = 0;
this.targ = 0;
this.cmin = clamp_min!=undefined ? clamp_min : Number.NEGATIVE_INFINITY;
this.cmax = clamp_max!=undefined ? clamp_max : Number.POSITIVE_INFINITY;
}
axis_integrator.prototype.set = function(v){this.targ = v}
axis_integrator.prototype.set_max_speed = function(v){this.msp = v}
axis_integrator.prototype.changed = function(dt){
var ob = this.speed;
var dm = this.mac*dt;
if(this.targ > ob+dm)
this.speed += dm;
else if(this.targ < ob-dm)
this.speed -= dm;
else
this.speed = this.targ;
var ov = this.value;
this.value += this.speed*this.msp*dt;
if(this.value < this.cmin) this.value = this.cmin;
if(this.value > this.cmax) this.value = this.cmax;
return ov != this.value;
}
-
Thanks. It is working now. What values does the direction float3 {x:0.0,y:0.0,z:0.0} field of this.fire take? I know they're the same setup as the spotlight directions but as mine only needed orthog angles I got past them without really understanding them. Some direction values make the projectile speed and size really big or small.
-
Absolute value of the dir vector multiplies the speed, so you should keep it a unit vector (but that wasn't intended, I'll normalize it). It should not affect the size though.