Anixias
Member
Just for some increased visual performance in a real-time multiplayer game I'm developing, I would like to "roll-back" positions and reapply all input in order for an elapsed amount of time based on how long a player's "input" packet took to arrive.
Basically, I will store a circular buffer (basically a 2D array with a pos variable that increments and %= (mod) by the length of the array every increment) of past positions, input, and times for the other player (game is 2-player). When you receive an input/state packet for the other player, you should roll back to a certain index (x position) in the array based on how long the packet took to arrive, and overwrite the position (x,y) information, input information, etc. and resimulate, one frame at a time, the physics and positions for that player.
The reason why I want to do this is that currently, it's very noticeable that the other player stops moving, and slowly glides to their local position (the server is non-authoritative over player positions, since the game is just a story based game with no competitive aspect). They walk in a very bouncy/floaty manner right now, and it is not game-breaking at all, just annoying to look at.
The position of the other player has very little to do with the actual game properties. It's almost entirely just eye-candy that you can even see the other player. You cannot interact with them physically, and the server will just believe whatever the client says (again, cheating is allowed since there is no competition in the game).
Anyways, how can I calculate how many milliseconds (not seconds, it's too inaccurate) it took for a packet sent from one player to arrive at the other player? I had an idea that involved calculating weird stuff and sharing current_time between the players, etc. but it didn't have a direct answer and gamemaker has no way to get UNIX time in milliseconds (you can get it in seconds using date_time functions).
tl;dr
How can I calculate the amount of time a packet took to arrive at another player's machine? OR how can I calculate UNIX time in milliseconds (seconds are too inaccurate)?
Thank you so much.
Basically, I will store a circular buffer (basically a 2D array with a pos variable that increments and %= (mod) by the length of the array every increment) of past positions, input, and times for the other player (game is 2-player). When you receive an input/state packet for the other player, you should roll back to a certain index (x position) in the array based on how long the packet took to arrive, and overwrite the position (x,y) information, input information, etc. and resimulate, one frame at a time, the physics and positions for that player.
The reason why I want to do this is that currently, it's very noticeable that the other player stops moving, and slowly glides to their local position (the server is non-authoritative over player positions, since the game is just a story based game with no competitive aspect). They walk in a very bouncy/floaty manner right now, and it is not game-breaking at all, just annoying to look at.
The position of the other player has very little to do with the actual game properties. It's almost entirely just eye-candy that you can even see the other player. You cannot interact with them physically, and the server will just believe whatever the client says (again, cheating is allowed since there is no competition in the game).
Anyways, how can I calculate how many milliseconds (not seconds, it's too inaccurate) it took for a packet sent from one player to arrive at the other player? I had an idea that involved calculating weird stuff and sharing current_time between the players, etc. but it didn't have a direct answer and gamemaker has no way to get UNIX time in milliseconds (you can get it in seconds using date_time functions).
tl;dr
How can I calculate the amount of time a packet took to arrive at another player's machine? OR how can I calculate UNIX time in milliseconds (seconds are too inaccurate)?
Thank you so much.