Moved smoothing factor to server options

This commit is contained in:
Jeremiah Billmann
2013-07-09 20:12:54 -04:00
parent 56133d9c90
commit bb083ecb94
2 changed files with 5 additions and 4 deletions
+3 -1
View File
@@ -31,6 +31,7 @@ window.GarageServerIO = (function (window, socketio) {
this.interpolation = false;
this.pingInterval = 2000;
this.clientSidePrediction = false;
this.smoothingFactor = 1;
}
StateController.prototype = {
setTime: function (serverTime) {
@@ -191,6 +192,7 @@ window.GarageServerIO = (function (window, socketio) {
_stateController.interpolationDelay = data.interpolationDelay;
_stateController.pingInterval = data.pingInterval;
_stateController.clientSidePrediction = data.clientSidePrediction;
_stateController.smoothingFactor = data.smoothingFactor;
setInterval(function (){
_socket.emit('ping', new Date().getTime());
}, _stateController.pingInterval);
@@ -358,7 +360,7 @@ window.GarageServerIO = (function (window, socketio) {
if (positions.previous && positions.target) {
amount = getInterpolatedAmount(positions.previous.time, positions.target.time);
newState = _options.onInterpolation(entity.id, positions.previous.state, positions.target.state, amount);
entity.currentState = newState = _options.onInterpolation(entity.id, entity.currentState, newState, _stateController.physicsDelta * 20);
entity.currentState = newState = _options.onInterpolation(entity.id, entity.currentState, newState, _stateController.smoothingFactor);
}
}
});