Jump to content
  • Advertisement
Sign in to follow this  
igna92ts

How to order data in packets?

This topic is 913 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Ive been making a socketio server for realtime unity games just because and I encountered a problem. In my game each client objects tell the server their state with a simple struct with a couple a fields , nothing big and the server then broadcasts it to the rest of the clients. Since I use redis behind all clusters I had to check on a timestamp I sent with each packet to be sure Im not overwriting updates with old data from another client that happened to arrive a little late. Doing this did improve the problem but still theres something wrong with the way im doing things as it doesnt work as intended (some updates are positions) and , for example, with an object falling , the object goes back up a little every couple of frames. I can tell what the problem is but I dont really know how to fix it. How do I take in to account that if an object is falling no to take data that positions it above the position in the previous packet without making handlers for each physics event and input??

Share this post


Link to post
Share on other sites
Advertisement

I don't have any formal knowledge in the area of networking and socket programming, but have you considered interpolating values based on time stamp to try and smooth that stutter you are seeing? I feel like that's a thing...

Share this post


Link to post
Share on other sites

It might help to delay the broadcasting of messages for a short time (like 1ms) to wait for messages with earlier timestamps to come in, and then broadcast messages in proper time-order. This would require time stamps with greater than 1ms precision though.
The problem could be because of how you're sending the data to begin with. For example, if you're sending position updates instead of velocity updates, it might minimize the issue to do velocity updates.

Share this post


Link to post
Share on other sites

I've only ever made local network multiplayer games, but I always assumed you could always drop packets older than the ones you handled, unless they have critical information.

 

So if a packet has movement data in it that's old, you can just drop it if you have something newer.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!