Hey guys,
I have a question for anyone that knows how to write netcode handling pretty well or those that have a good idea.
I have written a game where multiple players can join and play over the net, My question is about how to best handle player positions without having major lag or glitchy performance.
Using a game like flappy bird as an example(no my game has nothing to do with flappy bird :-)), but I want it to be multiplayer, so I when I open the app I add my local player, it has a physics body of type dynamic so it can flap and fall based on gravity.
Player 2 joins I add another player object but this player has a physics body type static otherwise between position updates from the server the player 2 tends to drop if it missed a position packet.
anyway the real question is based on what data to send and how often, my app is set at 30fps and on every frame I am sending the x,y coords of the local player to noobhub which in turn is broadcasting this back to all the connected clients, they read the position of each other player and move them accordingly. This works very well when I run Noobhub on my local network with as many devices as I can gather all playing together. but there is a slight glitch or small jumps once in a while with the remotely connected players. When I run Noobhub on a hosted IP with more hops to traverse of course the performance takes more of a hit.
So it seems sending 30 packets a second per client seems extremely overkill, and way too much overhead, but since I am new to writing a multiplayer game like this I am wondering what the best way to handle position updates for all players in a game? also should I have a timestamp or sequence ID on each packet and ignore packets if they are out of sequence as that can happen with UDP?