I have a use case where I have a turn based billiard style game and I am using this library.
All works well - however, after my initial turn, and I try to hit the ball, it seems to want to move slightly, stop, then after the interpolation buffer I have set (150ms) it will move again and follow through.
My hacky way of fixing this is re-initalizing the SnapshotInterpolation object after each turn to remove all snapshots from the vault.
It seems to be after the first turn, the library retains all previous snapshots and causes a slight delay when the ball will move again because of the interpolation buffer I have set.
Could we include an option to clear the vault? Or perhaps there is a better way to fix this stopping issue?
Some of my source code below:
Apologizes for the ugly code snippet could not get it to format correctly.
`
const snap = this.SI.calcInterpolation('x y');
if (!snap) return;
console.log('snap count: ',this.SI.vault.size)
const { state } = snap;
if (!state) return;
state.forEach((ball) => {
// console.log(state)
//@ts-ignore
const _ball = this.playerBallGroup.getBallById(ball.entityId);
if (!_ball) return;
//@ts-ignore
_ball.setX(ball.x);
//@ts-ignore
_ball.setY(ball.y);
});
public resetSnap() {
this.SI = new SnapshotInterpolation(30);
this.SI.interpolationBuffer.set(150);
}
Hello,
I have a use case where I have a turn based billiard style game and I am using this library. All works well - however, after my initial turn, and I try to hit the ball, it seems to want to move slightly, stop, then after the interpolation buffer I have set (150ms) it will move again and follow through.
My hacky way of fixing this is re-initalizing the SnapshotInterpolation object after each turn to remove all snapshots from the vault.
It seems to be after the first turn, the library retains all previous snapshots and causes a slight delay when the ball will move again because of the interpolation buffer I have set.
Could we include an option to clear the vault? Or perhaps there is a better way to fix this stopping issue?
Some of my source code below: Apologizes for the ugly code snippet could not get it to format correctly.
` const snap = this.SI.calcInterpolation('x y');
public resetSnap() { this.SI = new SnapshotInterpolation(30); this.SI.interpolationBuffer.set(150); }
`