Jump to content
  • Advertisement
Sign in to follow this  

Player movement

This topic is 4718 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Im writing a basic multiplayer game and I want peoples views on the best way to handle player movement within a game. I have read various ways, but whats the best? I could send the keypresses of the client, update the clients position on the server as appropriate, channging the direction depending on any other keypresses, then relay to each other client every 20 frames or so. (i think this will result in uber lag) Or, send the positons directly (more uber lag) So hmm, whats the best methods? Cheers!

Share this post


Link to post
Share on other sites
Advertisement
Personally, I like to send movement updates for each player 2-4 times per second for other players that are in a client's immediate vicinity. For others farther off, you can be convervative and give them more sporadic updates.

Although for the packets themselves, I generally tend to include:


-> The delta X and Y coordinates (assuming 2D game, otherwise add in a Z :P)
-> The current X/Y(/Z) velocity (condensed/rounded into a smaller integer type to save bandwidth)
-> The ID of the client in question


This should come to 7 bytes or so depending on how big the datatypes you need. Of course, this is assuming that your game makes use of player velocity, and movement isn't turn-on-a-dime-esque. If you're writing a tile-based game, then your job is even easier: you only need to send the X/Y delta of the client.

But to give any more specific advice you'd probably need to tell us what kind of game you're making that the movement is for. :)

(Hope something in that blabble helped :P)

Share this post


Link to post
Share on other sites
The various methods are overviewed in the material pointed at by the FAQ.

If you're making a basic RPG, sending updates twice a second is likely good enough. If you're making something kinetic, like a FPS, or just a very "physical" RPG, then you probably want to go with an FPS-style model, or a input-synchronous model, where you forward data at least 10 times a second.

Whether you forward keypress data, or baseline data, is mostly a matter of how many players you want to support, how sensitive to packet loss you want to be, and how much work you want to cut out for yourself.

Share this post


Link to post
Share on other sites
Well its a small mmo game but I didnt want to say, I know how people get slated on these forums for trying mmo. But then again im not aiming high its more of a prototype :)

its an mmorpg style game, probably 2d so i will go for the 2 to 4 times per second.

Any further advice?

Share this post


Link to post
Share on other sites
Quote:
Original post by Asheh
Well its a small mmo game but I didnt want to say, I know how people get slated on these forums for trying mmo. But then again im not aiming high its more of a prototype :)

its an mmorpg style game, probably 2d so i will go for the 2 to 4 times per second.


On this forum people are pretty civil. I'd shoot a sidelong look at you, but never slander your game choice. ;)

Quote:
Any further advice?


Not without more information about how your actual movement works. :P If you'd feel more comfortable discussing it over MSN/AIM/etc, send a PM my way and we could discuss it in more detail. :)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!