Original Post
Hello,
We're trying to write a network synchronization for a physics based 2D shooter (in Java)(website). Its our second attempt but we feel it won't work again.
Our first attempt was:
1) Server builds sync packages which contain position + rotation updates all as byte arrays
This usually ended in a mess with Java's ByteBuffers but we got it working for some basic parts
2) Client receives sync packages and decodes the byte array and applies updates
Like for 1) it was a mess with bytes
3) Important events like "add physics body" or "shoot gun" had to be sent to server and acknowledged/accepted before client could add a bullet
Bullets are physic bodies too. Adding physic bodies (same fore loading the level) also was a command witch was nearly 100% synced over network.
But all together never worked well over network and after a while every thing starts to slow down on the client side or events were applied seconds after they were physically sent.
The protocol was written using a UDP socket. I implemented functions that could guarantee package transfer and functions that did not guarantee but gave a good speed. The unsecure functions were used for 1) and 2) and the secure functions were used for 3)
Our main question is: Is there a much easier way to implement a working synchronization over the network? Are there any libraries that do exactly what I need here?
Is Java's serialization API something that could help?
Thanks for any comment!
We're trying to write a network synchronization for a physics based 2D shooter (in Java)(website). Its our second attempt but we feel it won't work again.
Our first attempt was:
1) Server builds sync packages which contain position + rotation updates all as byte arrays
This usually ended in a mess with Java's ByteBuffers but we got it working for some basic parts
2) Client receives sync packages and decodes the byte array and applies updates
Like for 1) it was a mess with bytes
3) Important events like "add physics body" or "shoot gun" had to be sent to server and acknowledged/accepted before client could add a bullet
Bullets are physic bodies too. Adding physic bodies (same fore loading the level) also was a command witch was nearly 100% synced over network.
But all together never worked well over network and after a while every thing starts to slow down on the client side or events were applied seconds after they were physically sent.
The protocol was written using a UDP socket. I implemented functions that could guarantee package transfer and functions that did not guarantee but gave a good speed. The unsecure functions were used for 1) and 2) and the secure functions were used for 3)
Our main question is: Is there a much easier way to implement a working synchronization over the network? Are there any libraries that do exactly what I need here?
Is Java's serialization API something that could help?
Thanks for any comment!