Lots of moving objects


I am programming a multi user space game, with a central server, and a client.

On the server, I am using bullet to apply physics on node. The server runs AI.
On the client, I send key pressed to server, and the physics is applied in central.
The client receives its own move (player’s move), and the AI moves, and other player moves.
An interpolation is done between actual position on the client, and the server’s position received.

The client stores the received message in a hashmap, and each loop, looks at its own type of message (npc update, player update, new bullet,…) based on an id.

I have a huge loop, which runs each object individually (ships, bullet, …). Almost object will look at a network received message, and next will “move”.

From this, not using thread for objects, each loops take between 0.05 and 0.08, and my framerate drops to 15fps.

I got 30 nodes + 100 nodes of bullet I think. I don’t think it is an huge amount of nodes? or maybe it is for panda?

I am afraid to have to thread each object to not be in the render loop, but into individual move loop.

What do you think about it? Do you have any advice?

Thank you

I have a similar setup in my game.
Am I correct to assume that the server is running at a good frame rate, but the client frame rate is low?

Are you sending the data for each object in an individual message? If so you can probably benefit by packing all the data to update each frame into one big message. Also make sure you are using UDP for anything that is time sensitive (everything except initial connection and maybe chat messages).

Try setting up some performance profiling with PStatCollectors, so you can see specifically what type of update is costing more time.

Hum, in fact, I am not using UDP.
It is maybe the first problem.

My question, is how to pack the information.
For example, I am sending position, with a message like this
– Id ship
– posX
– posY
– posZ
And I know my message is an integer following by three floats.

What have I to do, is:
– nbshiptoupdated
– idship1
– posX1
– …

Is that right?

Yep, that is pretty much exactly what I do.

I have several “types” of objects, so I send a type number after the id as well, since different types of objects have a different amount of data I need to send. For example you might want to send how much ammo a friendly ship has, but how much ammo an enemy ship has is irrelevant.

Ok, You pack a very lot of information in one send.

Today, I was sending one information per information.
– position of enemy : enemy by enemy
– rotation of enemy : enemy by enemy
– position of players : player by player

It makes a lot of communication indeed…