1
\$\begingroup\$

i am currently having a struggle thinking about syncing bullets. I am using node js and phaser.io and I am creating top-down shooter.

  1. I would do it like this: Player shoots a bullet. Player sends information where that bullet is Player2 gets information and updates their bullet.

But the problem is, when client window is out of focus. Physics are paused and so are bullet movement, which is horrible for multiplayer game.

How can I achieve synced bullet across two or more clients .

I tried searching for information about server sided physics for node, but I really couldn't find any.

Thanks

\$\endgroup\$
1
  • \$\begingroup\$ There are entire books written on the subject of multiplayer physics and a few by exactly that name. \$\endgroup\$
    – Bob_Gneu
    Nov 27, 2016 at 2:59

2 Answers 2

1
\$\begingroup\$

You need to go with a Server style architecture. By that I mean that all clients connect to a single instance, which would be hosted on the computer of the person that creates the server. Essentially, the clients don't keep track of the entities, that's the server's job. The players ping the server, and update their client with the information it provides. Think of it more like a nexus, where all players talk and communicate with each other through a single hub.

\$\endgroup\$
0
\$\begingroup\$

I'm not sure what you want to achieve. You could avoid pausing the game when it is out of focus:

game.stage.disableVisibilityChange = true;

or given the latest position of the bullets just update them when the game is unpaused. In this case is possible that the bullets have hit something/someone and no longer exists, but the general idea is to update the client with the latest status given by the server.

\$\endgroup\$
1
  • \$\begingroup\$ One noteworthy aspect is that pausing and unpausing is just an artifact of testing on the same machine. The problem is really one of networking and synchronization. \$\endgroup\$
    – Bob_Gneu
    Nov 27, 2016 at 3:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .