This week we finally finished our first 2-week goal (although it actually took us 3 weeks). We encountered a ball synchronization problem in multiplayer networking and it blocked us for a couple of days. Fortunately, we managed to come up with a reasonable solution after consulting with several faculty. We held a playtest session with high schoolers from River Valley high school on Friday.

Ball Synchronization

The problem we encountered was the how to transfer the ownership of the ball when played in a multiplayer scene. The owner of the ball will calculate the ball’s position for the next frame and broadcast the information to all other clients in the scene.

At first, we didn’t transfer the ball ownership at all and let the host player be the owner of the ball and do the calculation at all time. The problem was that, since the client’s paddle position is broadcasted to the host with a relative low frequency, it could never actually hit the ball on the host’s end. From the client’s view, the ball is hit and starts travelling for about 1/4 a second and then reset to its previous position.

Then we realized the ball’s ownership needs to be transferred among the players as the game progresses. So our next idea was to transfer the ownership to the current player by calling whenever the hitting function is called. Yet, even though we ask for the transfer when the hit happens, it is not happening instantaneously. The process requires sending signal to the Photon server, confirming by the server and sending back the signal to the new owner. Thus, the behavior ended up having no difference than the previous version.

Finally, we came up with a walkaround that cracked this problem: we detect the distance between each paddle and the ball and select the player whose paddle is the closest to the ball to be the owner. As a result, in singles mode, the ownership would be transferred at the moment the ball cross the net and leave enough time for signals to be sent out and confirmed. This solution gave the player making the hit authority on the ball’s position and resulted in a smooth hitting experience.

Playtest

Thanks to Anthony, we were able to playtest our first demo with 10 high schoolers from River Valley high school and listened to their feedback.

Takeaways

  • People are moving paddles in all different ways
  • Instant feedback should be of top priority after halves
  • Lobby and voice comms are important for the game to be social

Art

Categories: Blogs