mirror of
https://github.com/RandomityGuy/MBHaxe.git
synced 2025-10-30 08:11:25 +00:00
fix spectate bug
This commit is contained in:
parent
2416a7119e
commit
87ff14b6b8
3 changed files with 22 additions and 13 deletions
|
|
@ -389,7 +389,7 @@ class CameraController extends Object {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var marblePosition = level.marbles[spectateMarbleIndex].getAbsPos().getPosition();
|
var marblePosition = @:privateAccess level.marbles[spectateMarbleIndex].lastRenderPos;
|
||||||
var up = new Vector(0, 0, 1);
|
var up = new Vector(0, 0, 1);
|
||||||
up.transform(orientationQuat.toMatrix());
|
up.transform(orientationQuat.toMatrix());
|
||||||
var directionVector = new Vector(1, 0, 0);
|
var directionVector = new Vector(1, 0, 0);
|
||||||
|
|
|
||||||
|
|
@ -2123,7 +2123,10 @@ class Marble extends GameObject {
|
||||||
}
|
}
|
||||||
physicsAccumulator += timeState.dt;
|
physicsAccumulator += timeState.dt;
|
||||||
|
|
||||||
if (this.controllable && this.level != null && !this.level.rewinding) {
|
if (this.controllable
|
||||||
|
&& this.level != null
|
||||||
|
&& !this.level.rewinding
|
||||||
|
&& !(Net.clientSpectate || Net.hostSpectate)) { // Separately update the camera if spectate
|
||||||
// this.camera.startCenterCamera();
|
// this.camera.startCenterCamera();
|
||||||
this.camera.update(timeState.currentAttemptTime, timeState.dt);
|
this.camera.update(timeState.currentAttemptTime, timeState.dt);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1506,26 +1506,28 @@ class MarbleWorld extends Scheduler {
|
||||||
}
|
}
|
||||||
// marble.unpackUpdate(ourMove);
|
// marble.unpackUpdate(ourMove);
|
||||||
// needsPrediction |= 1 << Net.clientId;
|
// needsPrediction |= 1 << Net.clientId;
|
||||||
if (ourMoveStruct != null) {
|
if (!Net.clientSpectate) {
|
||||||
var ourPred = predictions.retrieveState(marble, ourMoveStruct.timeState.ticks);
|
if (ourMoveStruct != null) {
|
||||||
if (ourPred != null) {
|
var ourPred = predictions.retrieveState(marble, ourMoveStruct.timeState.ticks);
|
||||||
if (ourPred.getError(ourMove) > 0.01) {
|
if (ourPred != null) {
|
||||||
|
if (ourPred.getError(ourMove) > 0.01) {
|
||||||
|
// trace('Desync for tick ${ourMoveStruct.timeState.ticks}');
|
||||||
|
marble.unpackUpdate(ourMove);
|
||||||
|
needsPrediction |= 1 << Net.clientId;
|
||||||
|
predictions.clearStatesAfterTick(marble, ourMoveStruct.timeState.ticks);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
// trace('Desync for tick ${ourMoveStruct.timeState.ticks}');
|
// trace('Desync for tick ${ourMoveStruct.timeState.ticks}');
|
||||||
marble.unpackUpdate(ourMove);
|
marble.unpackUpdate(ourMove);
|
||||||
needsPrediction |= 1 << Net.clientId;
|
needsPrediction |= 1 << Net.clientId;
|
||||||
predictions.clearStatesAfterTick(marble, ourMoveStruct.timeState.ticks);
|
predictions.clearStatesAfterTick(marble, ourMoveStruct.timeState.ticks);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// trace('Desync for tick ${ourMoveStruct.timeState.ticks}');
|
// trace('Desync in General');
|
||||||
marble.unpackUpdate(ourMove);
|
marble.unpackUpdate(ourMove);
|
||||||
needsPrediction |= 1 << Net.clientId;
|
needsPrediction |= 1 << Net.clientId;
|
||||||
predictions.clearStatesAfterTick(marble, ourMoveStruct.timeState.ticks);
|
// predictions.clearStatesAfterTick(marble, ourMoveStruct.timeState.ticks);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
// trace('Desync in General');
|
|
||||||
marble.unpackUpdate(ourMove);
|
|
||||||
needsPrediction |= 1 << Net.clientId;
|
|
||||||
// predictions.clearStatesAfterTick(marble, ourMoveStruct.timeState.ticks);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1968,6 +1970,10 @@ class MarbleWorld extends Scheduler {
|
||||||
for (client => marble in clientMarbles) {
|
for (client => marble in clientMarbles) {
|
||||||
marble.updateClient(timeState, this.pathedInteriors);
|
marble.updateClient(timeState, this.pathedInteriors);
|
||||||
}
|
}
|
||||||
|
if (Net.clientSpectate || Net.hostSpectate) {
|
||||||
|
// this.camera.startCenterCamera();
|
||||||
|
marble.camera.update(timeState.currentAttemptTime, timeState.dt);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
for (marble in marbles) {
|
for (marble in marbles) {
|
||||||
marble.update(timeState, collisionWorld, this.pathedInteriors);
|
marble.update(timeState, collisionWorld, this.pathedInteriors);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue