Jump to content

Help Moving Player Using Socket.IO and Phaser


Vinny Guerrero
 Share

Recommended Posts

Hi everyone!

I recently started using Phaser v3 and I’m enjoying it a lot. However, when it comes to using socket.IO I’m getting a little bit lost on updating multiple players at once. ( update loop I guess? )

I’m using this tutorial to set up a Pathfinding system

And this one for multiplayer settings

However, I ran myself into 2 big problems.

  1. I can’t update players positions to other socket connections, just the active one (current browser).
  2. I can’t move players on AWSD keys properly, just by clicking.

Can you guys please give some tips or ideas on how to fix this? I’m feelin’ a lil’ bit lost in this, kinda ran out of ideas on how to fix it =(

This is my game repo https://bitbucket.org/vini-guerrero/phasergame/admin

I would really appreciate some help to understand this better…

Thanks in advance!

Best regards from Brazil!

Edited by samme
links
Link to comment
Share on other sites

Thanks for the reply @Flowan...

After a few researches I've found out that my problem is called "game interpolation" which is adjusting entities to update loop using socket events.

That example is really good ( and complex ) I'm trying to break in parts to get just the idea I need to fix my game.

I've removed the permission on the repo ( https://bitbucket.org/vini-guerrero/phasergame/ )

What I'm trying to understand is... if the other players movements should be handled in the game.load function / game.init function or game.update function.

I've created the players Array, I was able to socket emit the list for all players connected, but I can't move synchronizing all of em inside the array.

Why is it so simple to do on click events, but when it comes to keyboard strokes, it gets so complex?

Link to comment
Share on other sites

click events you know where the destination is, therefore you can easily send the destination of where you're moving to the server, then the server just broadcasts to everyone else as a dumb middleman, and all the clients then render that character moving to that spot.

movement with keys however, you don't really know where the person is traveling to.  thats what makes it really hard.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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