Hi !
Featured games (85)
games approved by the League of Dukes
Games in Showcase (636)
Games in Android Showcase (178)
games submitted by our members
Games in WIP (688)
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  
  Best way to sync physics between client/server?  (Read 2259 times)
0 Members and 1 Guest are viewing this topic.
Offline Jacob_

Junior Devvie

Projects: 3

« Posted 2010-04-11 23:49:15 »

I've been working on integrating networking into my sandbox game. Right now, the way I'm handling the physics is letting the clients do their own simulating, and having the server send 2 sync packets: linear and angular velocity every second, and position every 3 seconds. Sounds good, but lag (even when the client and server are both localhost) causes problems when more than a few bodies are in the world. Is there a better way to do this?

This is a 2D game, I'm using the JBox2D engine.

Right now I'm doing physics and drawing in the same thread, so I guess that could be part of the problem.
Offline delt0r

JGO Knight

Medals: 33
Exp: 18 years

Computers can do that?

« Reply #1 - Posted 2010-04-12 14:06:00 »

My physics uses all ints/longs so that once things are "synced" they stay synced. Then I progress frame by frame, with hash checks on the state. All events are "synced" up on the same frame in all clients. The server tells them what frame events happen on. If a client gets out of sync it missed an event --it regets the events from the last correct hash check. and then "replays" as fast as it can to catch up. 

I have had no problems with 100k things, boids and simple physics.

Note that with strict match you could get the some syncing, but ints are easier on the network.

I have no special talents. I am only passionately curious.--Albert Einstein
Pages: [1]
  ignore  |  Print  
You cannot reply to this message, because it is very, very old.

Dwinin (76 views)
2015-11-07 13:29:08

Rems19 (82 views)
2015-10-31 01:36:56

Rems19 (82 views)
2015-10-31 01:32:37

williamwoles (108 views)
2015-10-23 10:42:59

williamwoles (94 views)
2015-10-23 10:42:45

Jervac_ (113 views)
2015-10-18 23:29:12

DarkCart (138 views)
2015-10-16 00:58:11

KaiHH (119 views)
2015-10-11 14:10:14

KaiHH (160 views)
2015-10-11 13:26:18

BurntPizza (174 views)
2015-10-08 03:11:46
Rendering resources
by Roquen
2015-11-13 14:37:59

Rendering resources
by Roquen
2015-11-13 14:36:58

Math: Resources
by Roquen
2015-10-22 07:46:10

Networking Resources
by Roquen
2015-10-16 07:12:30

Rendering resources
by Roquen
2015-10-15 07:40:48

Math: Inequality properties
by Roquen
2015-10-01 13:30:46

Math: Inequality properties
by Roquen
2015-09-30 16:06:05

HotSpot Options
by Roquen
2015-08-29 11:33:11 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!