Jump to content

Phaser movement "vibrates" issue


Theorems
 Share

Recommended Posts

Hello,

I just started learning phaser and websockets a few days ago and I am having troubles getting smooth movement when sending positions through a websocket. Every 20 milliseconds I send a packet to the client from my server with an array of all the players and their angles and coordinates. and everytime the update() method in the client is called I send a packet to the server with that client's updated values. I am currently using this to move my players (this bit of code is in the games update method):

    if(serverPacket != null){
    serverPacket.forEach(function(player){
        if(game.playerMap[player.id] != null){
            game.playerMap[player.id].body.x = player.x;
            game.playerMap[player.id].body.y = player.y;
            game.playerMap[player.id].angle = player.angle;
        }
    });

and it works well other than the fact that the player sort of vibrates while moving. I can easily copy paste an example of code and get smooth movement when I don't need to be sending the coordinates over a websocket but I can't seem to figure out how to make this work without the ugly vibrations when using socket.io...  (also the angle movement is nice and smooth - moving the x&y is what causes vibrations)

Thanks for any help!

Link to comment
Share on other sites

Ok I sort of figured out the problem and it has to do with my server not so much phaser. I assume the issue is starting when a packet gets lost. The client sends the server a packet of where it is currently, meanwhile the server sends the client a packet of where it thinks it should be. The client gets moved to the server's packet but meanwhile, the client's packet with the old position gets sent back to the server causing a loop between the last 2 moves causing the sprite to vibrate. I basically need to rethink how I am doing the client-server relationship to fix this I think.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

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