MarvinJ
MarvinJ

Reputation: 3

GoogleApi Real Time Multiplayer pushing updates

i am using the Google Api to create a Real Time Multiplayer - Top down shooter game with libGDX.

Player positions are send over "sendUnreliableMessage" on every call of the "render()" method :

The bullets shot by the players are send over "sendReliableMessage" like this :

The movement messages are send on each "render()" call. -Depending on the FPS around 30-60 times a second.

The bullet messages are send only when the "fire" button is pressed. Only once. And only the "creation position" of the bullet. Both Devices calculate updates on movement locally from this position.

My Problem and Questions are :

I tested only sending updates of the Player Position on movement. Then shot 4 times while standing still ( no "player position 'unreliableMessages' were send) and all 4 shots appeared on "Device B"

Which makes me think that "reliableMessages" are getting lost when i send "unreliableMessages" on every frame update ( again around 30-60 times a second ).

Upvotes: 0

Views: 107

Answers (1)

Teyam
Teyam

Reputation: 8082

If we rely purely with Sending game data, the way I understand it, you can implement sending data messages using the two messaging protocols provided by Google Play games services.

To answer your questions:

1. Updating the Player position like this is way to often right ?

You may still opt to use either of the two given messaging protocols. Just choose which suits you best, however, please note that your app is responsible for ensuring that the game behaves correctly if messages are dropped in transmission or received out of order.

2. Shots are getting lost. 1-3 of 4. Which is around 50-80% package loss.

With reliable messaging, data delivery, integrity, and ordering are guaranteed. You can choose to be notified of the delivery status by using a callback. But, to avoid losing some updates, please also note that there's a maximum size of messages that you can send for both reliable or unreliable messages.

In addition to what was given in the documentation, suggestion in this SO post - Real Time Multiplayer Best way for pushing updates on android might also help.

Upvotes: 0

Related Questions