unfix diagonal

This commit is contained in:
RandomityGuy 2021-07-02 13:27:28 +05:30
parent 200e99d4c0
commit 874c633e1c
2 changed files with 9 additions and 9 deletions

Binary file not shown.

View file

@ -336,11 +336,11 @@ class Marble extends GameObject {
var currentXVelocity = rollVelocity.dot(sideDir); var currentXVelocity = rollVelocity.dot(sideDir);
var mv = m.d; var mv = m.d;
mv = mv.multiply(1.538461565971375); // mv = mv.multiply(1.538461565971375);
var mvlen = mv.length(); // var mvlen = mv.length();
if (mvlen > 1) { // if (mvlen > 1) {
mv = mv.multiply(1 / mvlen); // mv = mv.multiply(1 / mvlen);
} // }
var desiredYVelocity = this._maxRollVelocity * mv.y; var desiredYVelocity = this._maxRollVelocity * mv.y;
var desiredXVelocity = this._maxRollVelocity * mv.x; var desiredXVelocity = this._maxRollVelocity * mv.x;
if (desiredYVelocity != 0 || desiredXVelocity != 0) { if (desiredYVelocity != 0 || desiredXVelocity != 0) {
@ -486,9 +486,9 @@ class Marble extends GameObject {
var dist = this._radius - contacts[k].contactDistance; var dist = this._radius - contacts[k].contactDistance;
if (dist >= 0) { if (dist >= 0) {
var f1 = this.velocity.sub(contacts[k].velocity).add(dir.multiply(soFar)).dot(contacts[k].normal); var f1 = this.velocity.sub(contacts[k].velocity).add(dir.multiply(soFar)).dot(contacts[k].normal);
var f2 = 0.016 * f1; var f2 = 0.1 * f1;
if (f2 < dist) { if (f2 < dist) {
var f3 = (dist - f2) / 0.016; var f3 = (dist - f2) / 0.1;
soFar += f3 / contacts[k].normal.dot(dir); soFar += f3 / contacts[k].normal.dot(dir);
} }
} }
@ -561,7 +561,7 @@ class Marble extends GameObject {
slipping = false; slipping = false;
} }
var vAtCDir = vAtC.multiply(1 / vAtCMag); var vAtCDir = vAtC.multiply(1 / vAtCMag);
aFriction = bestContact.normal.cross(vAtCDir).multiply(angAMagnitude); aFriction = bestContact.normal.multiply(-1).cross(vAtCDir.multiply(-1)).multiply(angAMagnitude);
AFriction = vAtCDir.multiply(-AMagnitude); AFriction = vAtCDir.multiply(-AMagnitude);
this._slipAmount = vAtCMag - totalDeltaV; this._slipAmount = vAtCMag - totalDeltaV;
} }
@ -576,7 +576,7 @@ class Marble extends GameObject {
aControl = aControl.multiply(this._brakingAcceleration / aScalar); aControl = aControl.multiply(this._brakingAcceleration / aScalar);
} }
} }
var Aadd = aControl.cross(bestContact.normal.multiply(this._radius)); var Aadd = aControl.cross(bestContact.normal.multiply(-this._radius)).multiply(-1);
var aAtCMag = aadd.cross(bestContact.normal.multiply(-this._radius)).add(Aadd).length(); var aAtCMag = aadd.cross(bestContact.normal.multiply(-this._radius)).add(Aadd).length();
var friction2 = 0.0; var friction2 = 0.0;
if (mode != Start) if (mode != Start)