Add landing physics

This commit is contained in:
asraelite 2018-03-04 12:50:52 +00:00
parent 9435e887a4
commit d85338d9f2
6 changed files with 38 additions and 18 deletions

View file

@ -66,12 +66,25 @@ export default class Ship extends Body {
})
}
resolveCelestialCollision(pos, cel) {
//debugger;
let theta = this.angleTo(...this.com, ...cel.com);
let angleToCom = this.angleTo(...this.com, ...pos);
let angle = angleToCom - theta;
let [force] = this.rotateVector(0, 1, angle);
if (Math.abs(angle) < 0.3) {
force *= -1;
}
this.rvel -= force * 0.015;
}
checkModuleCollision(module, body) {
let p = this.getWorldPoint(...module.localCom)
let p = this.getWorldPoint(...module.localCom);
let dis = body.distanceTo({ com: p });
if (dis < body.radius + 0.5) {
this.approach(body, dis - (body.radius + 0.5));
this.halt();
this.resolveCelestialCollision(p, body);
}
}