Multiplayer Pong: synchronizing ball & paddle

0 favourites
  • 13 posts
From the Asset Store
Do you best and gather as many balls as you can!
  • Hello fellas,

    following question: what is the best way to implement/synchronize the ball in the pong using C2 multiplayer plugin.

    The ball has bullet physics reflecting from solids. Normally on the host everything is displayed correctly, but on the peer sometimes the ball behaves not as expected, I think it's because of position syncing from the host. So the problem here, that the same ball is shared by host and peers and should be synchronized from both sides. Any ideas?

  • May be I shouldn't use a bullet behavior on the ball, but calculate reflection angle as a synced variable and animate the ball's position manually? Something like lasers are implemented in the multiplayer example?

  • Make sure the peer disables any behavior on the ball: 'sync object' will be moving it, and if any other behavior is still enabled it will conflict with the multiplayer movement.

  • Ok, I'll try that.

  • Unfortunately disabling all behaviors on the peer's side didn't help.

    Sometimes the ball doesn't reflect from the paddle or goes through the paddle on the peer's side (like at the moment when the paddle is being moved). I do understand why: the trajectory which was calculated on the host is not 100% in sync with paddle position on the peer side.

    I also tried disabling this on the peer side: getbit(Peer.inputs,0)=1 > Peer Simulate 8Direction pressing UP. Which mean the paddle is being moved only by position syncing from the host. In this case everything is displayed correctly, but movement happens with delay.

  • Wow really!! I'm working on a similar concept of pong with multiplayer support... (right now its a mess tho) I'm basing it on the chatroom tutorial but I'm having trouble sending the player to his room and keeping the host on his "host room" ... (looong story and there's reasons too) reading a bit more to see if i can fix what i have so far.

    [edit]

    • to be a bit technical
    • I'm attempting to keep the host and the player on separate rooms.
    • using a "portal like" action to send the ball to the other player (along with the trajectory angle and position in x)
    • it works well in theory I should be only sinc-ing when the ball comes in or goes out. and the marker.

    -at least in theory it should work. however I cannot test that theory outside the host room at the moment since my player never gets into his room and crashed the other browser window.

  • I built it similar to the multiplayer shooter example and it almost works, except of those issues which I mentioned above. Paddles are peers, bullet physics is calculated in the host, peer displays only position change which is broadcasted from the host.

  • If the ball does not do the same thing it's doing on the host, you're using 'Sync object' incorrectly. You should leave it to move the ball automatically, and not make any attempts to move it with events or behaviors on the peer. The host should do the collision check and make it bounce.

  • The thing is, when the peer only renders data from the host including paddle and ball movement, there's an unpleasant lag in response to the peer's input. If I move the paddle in the peer directly + sending inputs onClientUpdate (e.g. with 8 direction behavior), than I get this synchronization issues. In the shooter example, peer also moves the soldier directly with 8 direction behavior. I don't like how I've expressed myself, but I hope you understand what I mean.

  • OK, after reading the third MP-tutorial, I think there should be "ball hits paddle" lag compensation, in order to solve the above mentioned issues.

  • xoros How goes it so far? any progress?

  • Hi. I tried to create an explosion (create sprite) outside of the host and peer group to create it locally for host and peer but it seems the peer does not have collision checks enabled, is this true Ashley?

    Its a basic "on collision with ball" > create Explosion, Play Sound and it works fine on the host but the peer does not show the explosion or play any sound effect.

    When I add the Explosion sprite to sync it with position it is created at the peer, but do you really have to transmit the explosion creation/position via the multiplayer sync action, can't the peer create objects locally? And what about the sound, do I have to send data (set bit to 1) and then play the sound if the peer receives it?

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • agh!! I'm having the same issue .. ball going through peer's paddle (sometimes). I lowered the speed of the ball too, still happens randomly. Ideas?

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)