tips4design Posted April 10, 2015 Share Posted April 10, 2015 I am using Phaser P2JS for a multiplayer game which receives the state of the game from an authoritative server once every 300ms. The same game engine runs on the client, so before the next state is received the game extrapolates the current state (simply runs the game from the last known state). When the new state is received I update the positions of the players based on what the server sent me. Is there any simple way of integrating interpolation in the transition towards the new state, without affecting the P2JS physics caluclations. Current State1 -> Extrapolate -> Receive State2 from server -> Interpolate towards State2 -> Current State2 -> etc... So, from the above pipeline I want to make sure the interpolation between two states (eg Player.x = (Player.x + Player.newX) / 2) won't break the P2JS engine. Link to comment Share on other sites More sharing options...
tips4design Posted April 10, 2015 Author Share Posted April 10, 2015 I have partially solved this problem by simply doing the interpolation methond mentioned above: Player.x = (Player.x + Player.newX) / 2 I do the above computation in the update loop of the player, making sure to only interpolate small enough distances (if the distance is greater than MaxInterDistance, constant defined by me, then it will simply jump to that position). Link to comment Share on other sites More sharing options...
CtlAltDel Posted April 10, 2015 Share Posted April 10, 2015 I suggest you read: http://www.gabrielgambetta.com/fpm1.html Link to comment Share on other sites More sharing options...
tips4design Posted April 11, 2015 Author Share Posted April 11, 2015 I suggest you read: http://www.gabrielgambetta.com/fpm1.htmlThanks, but I read a lot about interpolation and network games, the problem was this specific implementation with Phaser and P2JS. I didn't want to break the physics loop somehow while directly setting positions for bodies. It turned out that everything works well, even though I directly set positions to bodies from time to time. Link to comment Share on other sites More sharing options...
Recommended Posts