Pregunta

I'm developing a kind of Pong-Game for two-player with Unity and AllJoyn for Android. The game uses Unity's built-in physics capabilities. I'm new to Unity network programming. As an entry point, I had used the chat example of AllJoyn.

I send the paddle position permanently (x-Position as double value). The ball position and velocity is sent at the start and every paddle hit to hold the game in sync.

Unfortunately, the sending takes a few second (Lag). In this way the ball jumps in updating the position and velocity.

How do I get an optimal synchronization with AllJoyn? How can I speed up the sending and receiving of the signal? Is the chat sample code as the entry point for multiplayer gaming not optimal? I am currently looking into the update function if a position has been sent. Is there another solution to know when a package (ball and paddle position) was sent from another player? There are tricks with AllJoyn for a good Multiplayer synchronization?

I have also tried the movement of the ball controlled entirely by each local game instance, and just relies on the paddle position being updated across devices. Here it comes to problems because the transmission of the paddle position is not fast enough.

Have you some tips for me, how to solve this problem? Thank you!

¿Fue útil?

Solución

You should try to send very small amount of data at rate of 30 FPS (30 data packet per second). If your game runs at 60 FPS, you should send it once for every 2 frames.

Many devices will be lagged because of the network speed (even WiFi) and the data will be buffered or pending by the underlying system.

I hope this help you.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top