Sign in to follow this  
zee_ola05

[Java UDP] Delayed reaction of Players

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.

[b]The Client[/b]
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
}

[b]The Server[/b]
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
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
[quote name='zee_ola05' timestamp='1318145484' post='4870700']
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?
[/quote]

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this