I was hoping someone could help me with a bit of quarterion code.
I'm trying to come up with a reliable method of scattering ships around the launch corridor of the station, where the further away the ship is the wider they are positioned.
Here's what I have so far:
Code: Select all
var dock = null;
var dockpos = null;
// find the dock object of the station so we can position launched ships
for (var i = 0; i < station.subEntities.length; i++) {
if (station.subEntities[i].isDock) {
dock = station.subEntities[i];
dockpos = station.position.add( //better formula for non-centered docks
Vector3D(
station.heading.direction().multiply(dock.position.z),
station.vectorUp.direction().multiply(dock.position.y),
station.vectorRight.direction().multiply(dock.position.x)
)
);
break;
}
}
That part gets the dock position of the station. I think it's fairly straightforward (lifted from one of Norby's OXP's, ILS I think).
Next, I'm working out a distance from station value, "dist", which is based on how long it's been since that ship launched. Essentially, for each minute the distance increased by 1000 meters.
I then add this distance value to the dock position:
Code: Select all
var pos = dockpos.add(station.heading.direction().multiply(dist));
That gets me a position directly along the launch corridor. It's the next bit I'm having trouble with. I just want to pick a random direction from that point and move off the launch corridor line by "dist / 2" meters. How do I get that to happen? My attempts so far have being kind of unpredictable - it either works, or the ship ends up back on the line, closer to the station and I run into them when I launch!