finally fix the fucking traplaunches PLUS uncapped delta T

This commit is contained in:
RandomityGuy 2021-07-06 17:58:40 +05:30
parent c48f9e3a73
commit 0174909310
3 changed files with 12 additions and 5 deletions

Binary file not shown.

View file

@ -35,7 +35,7 @@ class Main extends hxd.App {
override function update(dt:Float) {
super.update(dt);
marbleGame.update(hxd.Timer.dt);
marbleGame.update(dt);
// world.update(dt);
fpsCounter.text = 'FPS: ${this.engine.fps}';
}

View file

@ -146,18 +146,21 @@ class PathedInterior extends InteriorObject {
// currentPosition: currentPosition,
// velocity: velocity
// };
var thisTime = timeState.currentAttemptTime;
if (stopped) {
currentTime = stopTime;
thisTime = stopTime;
popTickState();
}
var transform = this.getTransformAtTime(this.getInternalTime(timeState.currentAttemptTime));
var transform = this.getTransformAtTime(this.getInternalTime(thisTime));
var position = transform.getPosition();
this.prevPosition = this.currentPosition;
this.currentPosition = position;
if (!stopped) {
this.stopTime = currentTime;
this.stopTime = timeState.currentAttemptTime;
pushTickState();
}
// if (!stopped)
@ -175,9 +178,12 @@ class PathedInterior extends InteriorObject {
}
public function recomputeVelocity(currentTime:Float, dt:Float) {
var transform = this.getTransformAtTime(this.getInternalTime(currentTime));
var thisTime = currentTime;
var transform = this.getTransformAtTime(this.getInternalTime(thisTime));
var position = transform.getPosition();
velocity = position.sub(this.currentPosition).multiply(1 / dt);
this.collider.velocity = velocity;
}
public function pushTickState() {
@ -198,6 +204,7 @@ class PathedInterior extends InteriorObject {
this.prevPosition = this.previousState.prevPosition;
this.currentPosition = this.previousState.currentPosition;
this.velocity = this.previousState.velocity;
this.collider.velocity = this.velocity;
// this.updatePosition();
}