Bullet, Networking hang

Hello panda3d forum. Here is simple racing game engine for panda3d:
http://yadi.sk/d/A1AEI6dMNQ5Dv
I added network support from tutorial. Everything works good, but after 30 seconds client and server hangs.
http://imglink.ru/pictures/27-04-14/4a7cadcebd78816775348357bd4a465f.jpg
Stack trace shows hang at function for client:

self.cWriter.send(myPyDatagram, self.myConnection)

and for server:

self.cWriter.send(myPyDatagram,aClient)

Can you tell me how to solve that problem?

Hi,

I had a quick glance at your code. From what I see you run a physics simulation on both sides, tha tis client AND server), and send datagrams from server to client, but never pick them up. Not handling incoming datagrams is what blows you up.

In my opinion the basic approach (running physics simulation on both sides) is not going to work at all. Both simulations will differ in state after some time, and continuously overwriting one simulation with results from the other simulation will blow up the simulation sooner or later.

A reasonable basic approach would be to

  • run physics simulation only on the server
  • on client use only “visual” nodes (This means no physics objects on the client side!)
  • send control information (user input) from client to server, and apply it to physics objects there
  • send object state (position, orientation, lin./ang. velocity) from server to client and update visual objects there

From here you need to optimize. Sending the transform of each object each server frame would result in high network load. The client should have some prediction mechanism in order to interpolate the transforms until new information arrives from the server. This is what the linear/angular velocity is usefull for.
Using such a “dead reckoning” algorithm the server needs to send only information about an object (1) after a longer time, or (2) when a major event occurs, e.g. a collision.

Here is an interesting article (not Panda3D related) about networked physics. You will find dozens more on the web: gafferongames.com/game-physics/n … d-physics/

One drawback is that game logic sometimes depends on querries on the physics scene (e. g. raycasts). You can:
1.) move this logic on the server side too, e. g. for character movement the client sends only the DESIRED movement direction to the server
2.) use Panda3D built-in raycasts etc.
3.) setup physics on the client too, but only using kinematic objects and update them using information from the server (unfortunately we don’t support running Bullet in “collision only” mode, which would be a better approach).

thank you enn0x