So I just did a simple multiplayer project, and only have two instances of one object during gameplay. i.e one instance for host and another for peer. Obviously, the object, let's call it Obj1, is synced along with it's position.
Now, as with most, the peer experiences lag, and the position it sees is delayed. I was going to look into reducing lag, when I thought about sending Obj1's position via a multiplayer message (every tick), instead of syncing positions.
I tested this by making a copy of Obj1, i.e Obj2.
So during gameplay.
Peer input is sent to Host via client input state > Host reads input and sets Peer's Obj1's position > Host now sends Peer's Obj1's position via a multiplayer message back to peer > Peer receives message and sets Obj2's position from the message. (Obj1's position is still synced so I can compare Obj1's and Obj2's position on Peer side)
From this I saw that, Obj2's position is more accurate. The position gets updated faster and hence more true to what Host sees.
Any comments on this?
NOTE that this is done every tick, and sending a message every tick is intensive. Plus it's prone to jitters. Obj2's position sometimes goes to (0,0) for a tick and get's back to wherever.
Develop games in your browser. Powerful, performant & highly capable.