Jump to content
  • Advertisement
Sign in to follow this  
w00

sending position to server

This topic is 2522 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

I'm workking on the basics of my client/server game protocol. I'm currently sending an object from the client to the server. But i'm not sure if the method i'm currently using is right. Here's what i'm doing:

My client uses a timer which is set to 50ms. So currently it sends a small object to the server at that rate (50 ms). The object that i'm sending looks like this:


class Actions {
public bool forward = false;
public bool left = false;
public bool backward = false;
public bool right = false;

public bool eulerX = 0f;
public bool eulerY = 0f;
public bool eulerZ = 0f;
}


So all it basically sends is wether or not a player is moving forward (or any other direction) and it's current rotation in the world.

This is send every 50ms to the server. And the server seems to react well on it. But that's ofcourse because i'm testing it locally. What if the player has a ping of 100...??

That means that when the client sends 1 packet it takes 100ms before it arrives at the server. But in that time the client already sended 2 more packets to the server (once every 50ms remember?).

Doesn't this mean that i will get huge problems this way when the client has a high ping?
So basically my question is, is it okay to send a packet every 50 ms to the server? And what happends when a player has a high ping? How do i handle that?



Just a side note. I just want to discuss about sending packets at a certain rate for movement only/rotation only. I know that when you take firing a gun and calculating the impact into account, that it becomes a bit more complex. But i know how to handle that.

Share this post


Link to post
Share on other sites
Advertisement
You always have some delay, whats the difference between 1ms and 1000ms? Technically none. The code itself stays the same and does the same. What matters is always the time on the server. Consider the servertime as right now and all clients as a bit delayed.

All you can do is make the players feel like there is no delay, for example you can develop an algorithm clientsided that estimates someones movement etc. - just for visual purposes.

the_visualist

Share this post


Link to post
Share on other sites
As the_visualist said, movement prediction is how you achieve a less laggy feel. There are a bunch of threads here about prediction, and some articles scattered around the web.

As a side note, you might want to pack all your bools into a bitfield, on most compilers bool will compile down to an 8 (Visual C++5.0 and later) or 32 (Visual C++4.2) bit type, so you'll be sending a lot of extra data.

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!