[Solved] Bouncing Balls in a multiplayer game

How would you implement a bouncing balls which physics is based on box2s (really libgdx wrapper but still)

The brute force method would be to send every position to every client

Should i just send forces that are applied at every collision

Depending upon the complexity and how much is going on.

I would probably have a ‘server’ that does the actual box2 collisions and calculations
Then just have the clients send input and receive positions. (You can just have the ‘host client’ act as a server too, and let the host client do the calculations)

If you have each client do collision, then everything is going to get out of sync really fast and you will likely have to do a lot more work to keep everything together.

However you could also make it seem slightly more ‘fluid’ by doing some interpreting and predicting on client side, but thats unnecesary if its likely just a minor amount of positional stuff.

So send every position change to all clients from the server doing the calculation is pretty what you are saying if i am understanding you perfectly

For a small project, this could be over-kill, but a nice way of handling online games is using snapshots.
Basically the clients send their data to the server and the server compiles a snapshot of all the data it has.
The server sends out something like 20 snapshots a second to the clients.
The clients then interpolate the position of everything based on their most recent snapshot.

This article talks a bit more about this method.
https://developer.valvesoftware.com/wiki/Source_Multiplayer_Networking

Depending on what you’re aiming for, you can have the server calculate all the collisions, or have the clients calculate collisions for objects they own.
The later takes the load off the server, but makes it vulnerable to hacking and extreme network latency.

Thank you both for responding so quickly

I think i am going to have the server do all the collision and send positions 20 times a second and interpolate between them

Thank you guys so much