Java-Gaming.org Hi !
Featured games (81)
games approved by the League of Dukes
Games in Showcase (513)
Games in Android Showcase (119)
games submitted by our members
Games in WIP (576)
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 2125 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 Duke


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 Knight


Medals: 27
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 Knight


Medals: 27
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.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Longarmx (41 views)
2014-10-17 03:59:02

Norakomi (33 views)
2014-10-16 15:22:06

Norakomi (26 views)
2014-10-16 15:20:20

lcass (30 views)
2014-10-15 16:18:58

TehJavaDev (59 views)
2014-10-14 00:39:48

TehJavaDev (60 views)
2014-10-14 00:35:47

TehJavaDev (50 views)
2014-10-14 00:32:37

BurntPizza (66 views)
2014-10-11 23:24:42

BurntPizza (38 views)
2014-10-11 23:10:45

BurntPizza (80 views)
2014-10-11 22:30:10
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
java-gaming.org 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‑gaming.org
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!