Hi !
Featured games (88)
games approved by the League of Dukes
Games in Showcase (681)
Games in Android Showcase (196)
games submitted by our members
Games in WIP (744)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Problem with Lag  (Read 2559 times)
0 Members and 1 Guest are viewing this topic.
Offline newsomjk

Junior Newbie

« Posted 2010-07-10 18:16:01 »

I'm currently working on an MORPG by myself coding from the ground up. I thought I had the basics of networking down, but when I change the IP from local host to the real IP there's serious lag issues.

Players can move around and see each other, but they skip horribly. This leads me to believe the way I'm doing the networking is way off. Currently the server is setup to broadcast player positions 33 times a second, and the client is set to update the screen and inform the server of it's position 33 times a second. I'm using output streams and sending lines such as "PXY 300 200" to the server as a means of updating positions.

How exactly should I go about fixing this skipping issue? Is it just completely horrible networking or is it the way I'm sending messages back and forth as strings?

Any help would be much appreciated, and source can be provided if that would help figure out the problem.
Offline zoto

Senior Devvie

Medals: 4

« Reply #1 - Posted 2010-07-11 10:19:35 »

When the client receives "PXY 300 200" does it blindly set the location to 300, 200 or is there an attempt to smooth this movement?
Offline delt0r

JGO Ninja

Medals: 107
Exp: 18 years

Computers can do that?

« Reply #2 - Posted 2010-07-11 13:16:52 »

There is quite a few threads here on the topic.  Basically synced simulation is the way to go, more or less.

However you should be careful to define exactly what you need.  If you don't expect more that say ~16 players at once, and if you don't have a massive game state, then something like what quake 3 does is the easiest way (again there are many threads, use google rather than the forum search).

Otherwise minecraft is doing very well, with massive numbers of people.

Oh by the way, 33 times a second is 30ms. Yet a 50ms ping is pretty common even with broadband, so you must consider "synchronization" very carefully.

I have no special talents. I am only passionately curious.--Albert Einstein
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline newsomjk

Junior Newbie

« Reply #3 - Posted 2010-07-11 17:10:49 »

Hmm, I never thought of that zoto. It does just blindly set it, but I thought with tcp it make's sure it receives every message in order so if it's receiving every new position shouldn't it still look smooth? (it should be receiving every 5 pixel movement, and the changes in frames which is how the local player moves... every 5 pixels and updated frames)

Well I doubt this game is ever gonna become too massive so it will probably be around 20 people at the most. And thanks for the suggestion about the ping, forgot about that too. I'll work on that.

Thanks for the help
Offline DavidX

Senior Newbie

« Reply #4 - Posted 2010-07-16 06:42:45 »

are you using tcp or udp?

if youre using tcp, its a better idea to collapse 10 (or so) move packets into a single packet and send one of those every second instead of a seperate move every 100ms. this way, the movement wont be held up as much as if you sent 10 move packets a second (because of tcp, if packet #1 fails to send, the client will send it again, and the server will need to wait for #1 to arrive again before it can process #2-#10.)

if youre using udp, sending 10 small move packets per second should be fine, as a lost packet shouldnt affect anything.

As stated above, you should also use some sort of interpolation (and perhaps extrapolation) to smooth out the movement.

 - David
Offline delt0r

JGO Ninja

Medals: 107
Exp: 18 years

Computers can do that?

« Reply #5 - Posted 2010-07-16 10:23:19 »

don't forget that UDP can also change the order of packets, so you need to handle that as well as dropped packets.

I have no special talents. I am only passionately curious.--Albert Einstein
Offline newsomjk

Junior Newbie

« Reply #6 - Posted 2010-07-26 02:42:06 »

Alright thanks for all the help, sorry bout the late reply I've been on vacation.

I've summed it up to making these changes:
- instead of transporting strings back and forth, I'm going to send objects between the client and server. Idk if its faster but it helps with organization
- condense 10 move packets into 1, and send those on a separate timer.
- fix up a graphical transition between old and new positions of distributed sprites.

I'll get to work on this when I can and hopefully the results will mean I don't have to ask for more help ha. Thanks again
Pages: [1]
  ignore  |  Print  
You cannot reply to this message, because it is very, very old.

Hydroque (43 views)
2016-06-22 02:17:53

SwampChicken (45 views)
2016-06-20 13:22:57

SwampChicken (44 views)
2016-06-20 13:22:49

SwampChicken (38 views)
2016-06-20 13:22:26

Hydroque (80 views)
2016-06-15 08:22:50

Hydroque (72 views)
2016-06-13 06:40:55

DarkCart (192 views)
2016-05-29 02:30:33

Hydroque (160 views)
2016-05-26 14:45:46

Mac70 (168 views)
2016-05-24 21:16:33

theagentd (151 views)
2016-05-14 18:38:35
Java Data structures
by BinaryMonkL
2016-06-13 21:22:09

Java Data structures
by BinaryMonkL
2016-06-13 21:20:42

FPS Camera Tutorial
by Hydroque
2016-05-22 05:40:58

Website offering 3D Models specifically for games for free
by vusman
2016-05-18 17:23:09

Website offering 3D Models specifically for games for free
by vusman
2016-05-09 08:50:56

Website offering 3D Models specifically for games for free
by vusman
2016-05-06 11:10:21

Website offering 3D Models specifically for games for free
by vusman
2016-04-29 12:56:17

List of Learning Resources
by SilverTiger
2016-02-05 09:39:47 is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!