I'm attempting my first multiplayer game and I'm exploring an approach that I hope will work. However, what I need is to be able to do some client side predicition with JME Physics. I'm wondering if anyone has any thoughts on the best way to go about this. What I'm thinking is that when client B receives an update from client A, it should take the translation, rotation, angularvelocity, linearvelocity and predict that location roughly 200ms into the future then set the object. For anyone who's done this before, does that sound about right? Is it possible?

Many thanks.

That’s the question Jimmy!

This is a problem I’ve been trying to solve for a while and at this point in time it doesn’t look like it is possible with ODE to do this.  I have written a couple game networking APIs if you’re interested.  They handle the majority of what you’re trying to do already:

JavaGameNetworking Abstract API -

ODENetworking JGN API implementation -

If you figure out a good way to solve this problem I would be happy to have your assistance in these projects as networking is a pretty complicated deal when you’re dealing with a lagged world. :)  The JGN project is functional and tested.  The ON project is moderately functional and I’m still testing it.


Hmm, well then, what I think I'm going to try is writing my own little prediction routine based on a brief history of the objects translation/rotation. Say maybe look at the last 2 updates and determine the projected values for 200ms (or the average latency) into the future. I would keep the normal physics engine running to fill in the gaps between updates and continue to update angular and linear velocity from the server (ultimately the client), but I would also have to come up with some way of smoothing the corrections (spatial transformer?) when things disagreed. Does this sound about right?

Speaking of smoothing, can I run a spatial transformation on a physics object without it conflicting with the physics controller (or whatever you call it)? Would they fight over control of the object and make it jerky?

You can force an object to a specific position and specify specific forces.  That's what my ODENetworking project does in its synchronization system.  I think you're approaching something a little too advanced if you haven't even gotten networking going yet to be honest.  I think you should get a multiplayer game created before you spend too much time worrying about lag.

I also don't think you realize the headache you'll be taking on if you are really trying to create a "physics predictor".  For small things you might get something to work with a few hundred lines of code…for large things it would take significantly more I should think.


I guess I didn't explain very well where I'm at currently at with the project. :slight_smile: I already have a working client/server mySQL driven persistent world (so far ships, planets, stars, nebula, stations) multiplayer game working on my LAN using the physics engine and the headquarter networking framework. It's very basic, but you can have two or more clients connect to the server fly around and shoot each other, etc… It works very well actually with no prediction. I basically just send the data I mentioned previously and it all looks good and smooth, but then again, it's on a LAN. I haven't tested it with high lag on the net and thought before I even did that, I'd try to head off some latency issues at the pass.

So are you suggesting to not bother with prediction? I thought that was sort of essential for online games? Are there any action based games that don't do some sort of prediction? I was working on the math this evening behind it. It seems fairly straight forward. Keep about the last 3 updates, look at the change in the deltas over the first two updates to predict the delta for the current update. Smooth, rinse, repeat.

I know I'm oversimplifying it a bit here, but what am I missing?

Some games uses prediction only for "interaction" (the player, shooting, hitting a wall, etc.). So only when you fire, "predict" where the spot will be that the user is aming at when it reaches the server. "predict" that the server won't send you to walk through a wall. That's done so the user, when shooting at something for example, won't have to accomodate for lag, and to make sure that the response to user input is immidiate. All this, while still preventing cheating.

Slowdive, in that case I would very much like your expertise in helping to finish up ODENetworking. :-p  The JGN project has a LaggedTransporter so you can simulate lag on the local network.  This would be a good way to test everything you're doing in a good simulated internet environment.  You can check out the latest code from CVS on those links above and give me your opinion.  I've been writing this because networking is such a complex issue to deal with in games and it doesn't make sense for everyone to have to write it over again every time they write a game.

Your help in this would be appreciated, or if there is a better way to go about it I'm happy to listen…I'm just trying to write this personally so I can have an API to utilize for writing my networked games.


Heh, well that's the problem, I don't have any expertise.  :smiley: I just sort of cobble stuff together and hope it works. The LaggedTransporter sounds like a good idea. I guess you just hold the packet on the server for x amount of time, then send it to simulate lag? I agree, it would be great to have a nice standardized networking lib for JME. Then people wouldn't have to bang their heads on issues like multithreading openGL compatibiblity and such.

I'll definitely share whatever I discover in my work with networking, but I'm sort of throwing it together quickly at this point and I'm not even sure I'm doing everything correctly. Have you had a look at Headquarter


Well, I would definitely like to encourage you to bang your head on my implementations if you have the time as it would seem pointless to be doing redundant work on this and anything you find about my code that is lacking I am happy to fix if you can point it out to me. :slight_smile:

The ODENetworking API is at a useable state now, it's just not as perfect as I would like it to be before I make a broad statement of its availability.  I hope no one else reads this. :-p


Hey all, just stumbled upon this thread and found it intresting. I am currently developing a MMORPG and have been looking in to this problem at uni with my AI teacher. I know this thread is a bit old but if anyone else is having this problem i suggest hitting google with these keywords;

Dead Reckoning - this is client side play when updates are slow, the client will use everything it knows about the objects around it to create intraction when lagging. If The dead reckoning is found to be off when the server updates do come the system interpotates betwen what true state (server) and predicted state. This works well if the world has well defined limits, eg limits on speed, turning, projectial velosity. If these limits are working only so much can happen in 500ms so the interpolation will be small.

Area of Intrest - this is an intrestion model I had a look at. There are a number of approches; AOI p2p - when dealing with players in your area of intrest p2p pipes are spawned reducing server updates (updates are sent once for the whole p2p group) this introduces a whole world of other issues but never the less intresting. Tiled Servers - the game world is seperated into tiles located on diffrent servers, these servers use events to comunicate and layered player grouping to deal with congestion; while this is a very very brief explnation this method has proven to be extreamly scalable and completely transperent.

there are many other methods if anyone is intrested i would love to expand on this but for now im out of time.

There are some mmorpgs I used to play and sometimes I would get lag.  I would see another player character suddenly move sideways or such across my screen rather quickly then go normally.  I figured out what was going on was the server sent the fact that playerX was moving in directionXY at speed Z.  Because of lag my client never received the fact that they moved, changed direction, etc… so in my client the physics engine kept moving them until it received an update.  At that point instead of suddenly warping the player from pointA to pointB it did it as smoothly as it could. 

I do know that there is currently no MMORPG that is true FPS.  You have games like CSS and L4D but they are only MORPG, they are not massive.  They are limited to 32 players or so because of the physics information required to process, that's my thinking anyway.

I'm hoping to write a morpg that allows some FPS.  There are a few things I'm going to see if they work well even with the golden rule "Never trust the client".

I know this is an old thread but does anyone know a way of doing prediction in ODE?

I want to try to implement my own Dead-Reckoning system using jME and Project Darkstar, the problem is that when a client receives a message from the server with the forces and position of an object it needs to make up for latency by predicting where the object should be and what forces need to be applied to it x m/s in the future (where x is the latency time).

Darkfrog, how are you doing this in JGN-Physics?


Yeah, that's dead reckoning without any client side prediction. I'm not building an MMORPG though I'm building more of an RTS with a very small number of players (between 2 and 5).

The objects that the players interact with are physical objects which can interact with each other so the clients need to be sync'ed. The problem is lag! Imagine this scenario: client A applies force f to object x at time t, A sends a message to the server with this information, Client B receives the message, but because of latency receives it at time t+lag, the object has already been moving on client A for t+lag so for both clients to be in sync client B needs to predict where object x will be after t+lag given force f.

Surely there's a way to do client side prediction but I'm not sure how in ODE :frowning: