Multiplayer Move

Need help with an engine or coding not on the list? Need help with a game or the website and forums here? Direct all questions here.
Post Reply
User avatar
hallsofvallhalla
Site Admin
Posts: 12031
Joined: Wed Apr 22, 2009 11:29 pm

Multiplayer Move

Post by hallsofvallhalla »

So I am building my Javascript MMO engine and I have actually come quite far. I am using some open source libraries to speed up the process. So I am looking at the movement for players and how to send movement to all clients. Currently the engine is built to accept key presses and it moves the player one block so to speak. So when a player holds down the up key they walk up but on the backend it is presses multiple times.
I am trying to come up with a good way to send that to the clients without multiple calls. What I normally do is one send on key down and one on depress but this engine will work different as I always run into issues with that method. Especially with syncing. Any thoughts on how to predict each movement?
User avatar
hallsofvallhalla
Site Admin
Posts: 12031
Joined: Wed Apr 22, 2009 11:29 pm

Re: Multiplayer Move

Post by hallsofvallhalla »

K i think i got it. I am using a path follower that builds a path (left, right, down, up) that moves the character. When the player clicks on the map it builds the route then sends the player on their way. This way I am only sending one path per click. Yippeeee!
Sim
Posts: 412
Joined: Sat Dec 26, 2009 5:37 pm

Re: Multiplayer Move

Post by Sim »

hallsofvallhalla wrote:K i think i got it. I am using a path follower that builds a path (left, right, down, up) that moves the character. When the player clicks on the map it builds the route then sends the player on their way. This way I am only sending one path per click. Yippeeee!
It will work for basic clicking. Synching players using node was hard for me. I still havn't mastered it but this was on a Tetris like game.

For ex: Once a player goes left right up left right up in an unusually manner or quickly, things get out of wack.
oRPG Creator - Make Your Own Browser Game
oRPG Creator on Facebook
User avatar
hallsofvallhalla
Site Admin
Posts: 12031
Joined: Wed Apr 22, 2009 11:29 pm

Re: Multiplayer Move

Post by hallsofvallhalla »

I know what you mean. It has been a real pain to sync so there will have to be some prediction in there as well for real time combat.
User avatar
Jackolantern
Posts: 10893
Joined: Wed Jul 01, 2009 11:00 pm

Re: Multiplayer Move

Post by Jackolantern »

Sorry, kind of late here! But yes, click-to-move (C2M) is definitely the way to go (versus K2M or keys-to-move) for real-time character movement in online games IMHO. Even beyond keeping the player synced, it also prevents you from having another terrible headache: server-side collision detection. Ugh! That is a true pain, and it also eats up tons of server resources. With C2M, you of course first check if the tile the player clicked is even a block they can stand in on the client to avoid a server round-trip if possible, but of course check that first on the server as well. If it is a tile they can stand in, then you run A* to see if there is a path the player can take to move to that tile. If there is, you queue up that movement path and then iterate through it during the server loop. With K2M, you have to keep players' movement as vectors, and compare their movement vectors to the collision map on every server loop, perform client-side prediction to make it smooth, etc. It is really a mess.

You can get creative and try to do without a server loop for C2M games and try to make it all event-based. The obvious benefits are the performance your server can get without a server loop (in some cases, possibly 10x more players can play on the same server hardware) and the ease of development, but the cons can be difficult for some games. Probably the biggest issue is enemy movement. With an event-based server, a character is either at their starting location or their ending location, and not technically anywhere in-between. This makes determining if a player moved through an enemy's aggro range difficult, and also complicates the coding for the enemy to chase the player if they got too close. I think some clever geometric algorithms could negate this, but then we are starting to creep back up in complexity again :ugeek:
The indelible lord of tl;dr
Post Reply

Return to “Advanced Help and Support”