3

I'm trying to make a multiplayer game in HTML5. I found lance.gg and play around. I modified the Pong game like this.

  • remove Paddle (only Ball left)
  • set gravity to (0, 0.1)
  • set Ball.velocity.y = -3 each time keyboard input space bar

And here is result https://youtu.be/MmQOqR71Df0. As you can see, it does not really sync over the window. How can I make it move smoothly between many players?

Gary Weiss
  • 668
  • 5
  • 12
boygiandi
  • 630
  • 10
  • 20

1 Answers1

1

The Ball.js class defines the following getter:

get bendingVelocityMultiple() { return 0.0; }

This instructs the client to ignore the server's velocity updates. The result is that the client and server velocities fall out-of-sync, and results in the video you captured.

If you set instead:

get bendingVelocityMultiple() { return 0.8; }

Then the problem will go away. Having bendingVelocityMultiple set to zero might be useful in other cases though, for example if you want to transplant the ball back to the center when a player has lost.

Take a look at the documentation for GameObject

Gary Weiss
  • 668
  • 5
  • 12
  • Thanks. I got it. Can you tell me how to create a ground object ? Like when the ball hit the ground, it stop falling. And how to detect if it hit some other objects with special shape ? – boygiandi May 18 '18 at 02:32
  • 1
    You may want to ask this as a separate question. But the gist of it is that you may not need a game object for the ground, since the ground does not need to synchronize to all players. – Gary Weiss May 19 '18 at 13:23