Jump to content

Tween problem in a Phaser multiplayer game


Moksha
 Share

Recommended Posts

Hi guys,

At first, I want to apologize for my bad english. I'll try to do my best.

I'm creating a phaser multiplayers game based on the tower defense concept. There is a wave of monsters who walks along a specific path during an undertermined time (until every monsters of the wave died).

 

Each monster of the wave is a sprite which has his own tween.

 

Here I encountered 2 problems :

 

    1) If I open a new tab in the browser running phaser, do some stuff, and come back to the tab with phaser, some tweens are crashing and the path of some of the monsters (not all) is not respected anymore. Do you know what could happened ?

 

    2) As a multiplayer games, Im using sockets to establish a communication between clients and server. When all clients are ready, the server give them the order to start the wave of monsters, the tween.start() is launched at the same time on every clients phaser instance.

But I noticed that, for some reasons I ignore, there is a small delay between clients, and the monsters are not at the exact same position in all browsers players. How could I fix that ?

Thank you all for taking your time to help me.

Link to comment
Share on other sites

I don't have anything for #1, but #2 - You are dealing with asynchronous play, you are always going to get differences in timing, because you don't control how the information (packets) move between your server and the clients. Different Clients will have different PING rates. Even on the same machine you will get timing differences. This is the reality of networked games. Also note that Phaser's physics system is non-deterministic, and even if you are not using the physics system, unless you are sure the RNG is deterministic, across different platforms, you can't be sure that things are all going to start in the same place/look the same. WRT the tween engine, you are also probably going to get differences depending on the specific computer's speed, frame rate, etc etc.  I'm assuming that you are not using a authoritative server setup... If you are, then a lot of these issues are lessened, as the client is just that, a dumb client, only taking in input and only displaying what the server sends it. If you are doing a more P2P style, where each client has some authority over its own state, then syncing all the clients becomes more difficult. 

 

Network games are hard. Like, really hard. Using a server authoritative model makes some things easier, but then you have to deal with client lag/responsiveness, and start doing interpolation/extrapolation... Like I said, networked games are hard, infact, IMO, the most difficult to make. Especially if you are doing something realtime, rather then turn based, which is still hard. 

 

Good luck!!

 

Peace

Jos

Link to comment
Share on other sites

Thank you for your answer Jos.

Yes, I'm doing more like P2P style. Each client has some authority over its own state but the server is checking regularly if the render is the same in all clients.

I will keep thinking about it and if I manage to make this game alive, I'll post you the link to see it :)

Link to comment
Share on other sites

  • 2 months later...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...