[Java UDP] Delayed reaction of Players

Started by
2 comments, last by hplus0603 12 years, 6 months ago
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!
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.
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.

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.
enum Bool { True, False, FileNotFound };

This topic is closed to new replies.

Advertisement