Jump to content
  • Advertisement
Sign in to follow this  
zee_ola05

[Java UDP] Delayed reaction of Players

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

Hi, I'm making a side-scrolling game where multiple ninjas(players) kill each other. I set the FPS to 25. This is how I designed the networking part of the game.

The Client
Update()
{
//send user input (keyboard) to the server
//receive the gameState from the server (Ninja properties - posX, posY, etc.)
}

Draw()
{
//draw the Ninjas with the properties received from server
}

The Server
Update()
{
//receive user inputs from clients
//update the game
//send gameState
}

What can you say about this design? There's gotta be something wrong because the reaction of the ninjas are very delayed but it reaches the 25 FPS that I set. Enlighten me please.
Is it okay that I use UDP here? or is TCP better?

Thanks!

Share this post


Link to post
Share on other sites
Advertisement
Process the player input on client side immediately (meaning update the ninja position), then send it to server. After the server has responded with the game state, correct the client positions in one way or the other.

Share this post


Link to post
Share on other sites
That kind of sucks though, because it means if you have a lot of lag, you'll be able to move around freely but will constantly be forced back by the server because you're moving too fast.
World of Warcraft actually solved this, but I'm not sure exactly what they're doing.
What happens in WoW is that you're allowed to move around freely without being corrected by the server, but everything around you will be lagging.

Share this post


Link to post
Share on other sites

What can you say about this design? There's gotta be something wrong because the reaction of the ninjas are very delayed but it reaches the 25 FPS that I set. Enlighten me please.
Is it okay that I use UDP here? or is TCP better?


The FAQ predicts that your problem is TCP_NODELAY.

If you show client movement ahead of time, most of the time, there will be no corrections, because the client predicted correctly.

WoW allows position cheating, AFAICT.

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!