I'm developing a little 1-4 multiplayer jump & run for the iPad and have a problem regarding the synchronization. The game uses the Game-Center p2p Connection to connect the devices.
Now my problem is,
what data should i send?
-> I have enemies, moving platforms, destructible blocks and Items.
- when should I send the data?
Here are my first approaches to sync the PCs (playable characters):
1)
- send position (x,y) every frame --> physics and character don't interact, the character is set to the transmitted position
Problem:
lots of data to send
the PC lags sporadicly
2)
- send user input whenever it changes --> physics and character interact, only the opponents button actions are simulated
Problem:
- the latency is not always the same, e.g. the time one button is pressed is not exactly the same on all devices. This means one PC runs longer/shorter on one device.
So what is the best approach to sync a little p2p jump & run game?
Thanks in advance. I appreciate your help.