9 Replies - 2142 Views - Last Post: 10 September 2010 - 08:09 AM Rate Topic: ***** 1 Votes

#1 KuroTsuto  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 42
  • View blog
  • Posts: 182
  • Joined: 13-February 09

Networking: Player Movement

Posted 03 September 2010 - 02:51 PM

Hey D.I.C.!

Sorry for the appearance of so many questions suddenly - I feel its better to separate my arising considerations into different posts to maintain a better focus on the question at hand.

This time around, I'm wondering about networking involved for player movement. It stands to reason that a click-to-move game in which the player clicks a location and the character moves to the clicked location would only require that the destination's coordinates be sent to the server/other players, as the same path-finding algorithm could be used both locally and remotely to actually move the player's character to that location. But what about for games that allow free movement via keyboard keys or some such?

I have a done some research into the topic, and it seems that a reasonable solution for games that use 8-directional movement for players (or something similar) is to send one message containing the player's current position, their direction, and their speed for initial movement and changes of direction, followed by another message containing their position and direction once they have stopped moving. I'm assuming that this is the standard method to deal with such movement, correct?

One situation that I've found no information on whatsoever is the networking involved for games where a player has completely free movement - say for example, direction determined by cursor location and directional movement determined by keyboard input. I do have an old license to the Torque Game Engine which I am sure holds the answer to my question, but I'm afraid that an attempt to comprehend the relative source would be in vain as I haven't much experience with the engine.

Thank you for any help that you might throw my way ;) (This is just a pre-liminary thank you... more thanks are sure to ensue :P )

~KuroTsuto

This post has been edited by KuroTsuto: 03 September 2010 - 02:52 PM


Is This A Good Question/Topic? 1
  • +

Replies To: Networking: Player Movement

#2 sparkart  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 115
  • View blog
  • Posts: 696
  • Joined: 16-February 09

Re: Networking: Player Movement

Posted 03 September 2010 - 04:44 PM

I don't quite understand where your problem is.

Just send the direction and coordinates. You can calculate the direction based on the movement keys or the mouse location, the results would be the same.
Was This Post Helpful? 1
  • +
  • -

#3 KuroTsuto  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 42
  • View blog
  • Posts: 182
  • Joined: 13-February 09

Re: Networking: Player Movement

Posted 03 September 2010 - 07:42 PM

I suppose you're right... I think I may have been dismissing the idea as I thought doing so might generate an unnecessary amount of network traffic, but perhaps not.

Anyway, thanks for the reply and insight ;)
Was This Post Helpful? 1
  • +
  • -

#4 sparkart  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 115
  • View blog
  • Posts: 696
  • Joined: 16-February 09

Re: Networking: Player Movement

Posted 03 September 2010 - 09:44 PM

Well, it would depend on your approach. Perhaps the way you are doing things WILL be too bandwidth hungry.

Could you share with us the method that you are using in detail?
Was This Post Helpful? 0
  • +
  • -

#5 KuroTsuto  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 42
  • View blog
  • Posts: 182
  • Joined: 13-February 09

Re: Networking: Player Movement

Posted 05 September 2010 - 09:17 AM

Please Pardon my late reply!

At the moment I have no specifics. I was more or less curious about the different approaches that were available, in order to choose which I though to be best for my current project. For now I may well implement a click-and-move behavior with some A* pathfinding, but perhaps I will revisit the movement at a later date and implement one of the other methods - or both.

Thanks again for your help!
Was This Post Helpful? 1
  • +
  • -

#6 crzytrane  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 3
  • Joined: 04-September 10

Re: Networking: Player Movement

Posted 06 September 2010 - 04:11 AM

You could look at existing games? In some games when you lag out or when the host quits the players sometimes just keep on running. This would be a good indication that they have used the method you suggested where there is a message getting sent that tells the client to keep this player running in this direction and another that tells them when to stop.

You could also add a type of slow speed reduction when the player stops moving, so that instead of an instant 100->0 stop it is smooth. You could try that mixed in with consistent synchronization every 2-5 sec and keep listening for changes in direction or speed. I'm not sure if that would work but it might be worth a shot
Was This Post Helpful? 1
  • +
  • -

#7 KuroTsuto  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 42
  • View blog
  • Posts: 182
  • Joined: 13-February 09

Re: Networking: Player Movement

Posted 06 September 2010 - 02:44 PM

Solid advice, crzytrane!!

I've hadn't thought to examine that disconnect behavior of many modern games!

There will certainly be some sort of elastic easing for movements to help smooth-over the discrepancies... as the project's based on Javascript, I think I should be able to incorporate the jQuery easing plugin to do just that easily enough ;)

On another note entirely, let me be the first to welcome you to the Dream In Code community! (apart from the automated message, that is :P)
Was This Post Helpful? 1
  • +
  • -

#8 metric  Icon User is offline

  • D.I.C Head

Reputation: 12
  • View blog
  • Posts: 183
  • Joined: 22-May 10

Re: Networking: Player Movement

Posted 09 September 2010 - 09:01 AM

hey KuroTsuto

I was just about to post this same question. A while ago I built a small top-down game. (At this point all you can do is walk around on a map) anyway I would like to try and turn it into a multiplayer after I add path finding.

If you could let me know what you came up with I would appreciate it!

Cheers Metric
Was This Post Helpful? 0
  • +
  • -

#9 reaper4334  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 16
  • View blog
  • Posts: 107
  • Joined: 01-November 09

Re: Networking: Player Movement

Posted 09 September 2010 - 03:47 PM

I don't know if this is any use to you, but I came a accross this rather interesting article yesterday, I haven't read the whole thing but it seems like it might give you a little help: http://msdn.microsof...e/cc163648.aspx

[Edit] Figured I should mention that the example code on the article I posted a link to is in C#, but most of the article seems to describe the theory so it should still be pretty useful.

This post has been edited by reaper4334: 09 September 2010 - 03:48 PM

Was This Post Helpful? 1
  • +
  • -

#10 KuroTsuto  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 42
  • View blog
  • Posts: 182
  • Joined: 13-February 09

Re: Networking: Player Movement

Posted 10 September 2010 - 08:09 AM

Metric said:

hey KuroTsuto

I was just about to post this same question. A while ago I built a small top-down game. (At this point all you can do is walk around on a map) anyway I would like to try and turn it into a multiplayer after I add path finding.

If you could let me know what you came up with I would appreciate it!
Cheers Metric


Certainly, Metric! My progress on the project has kind of halted for the moment as I make the move back to school, but I think I can still throw something your way ;). One of the most commonly used path finding algorithms is known as A*. Like many path finding algorithms, this one's node-based, which makes it fairly easy to implement into grid-based systems, but a little trickier otherwise. While usually fairly basic in theory, it's a solid place to start! There are also libraries available for almost every language if you don't want to build an implementation yourself. Anyway, here's a couple primers that I found to be considerably useful:

-http://www.policyalmanac.org/games/aStarTutorial.htm
-http://www.untoldentertainment.com/blog/2010/08/20/introduction-to-a-a-star-pathfinding-in-actionscript-3-as3-2/

Note that the second one is written in the scope of ActionScript, but the theory is all solid, and the code provided wouldn't take too much work to port to another language ;).

With the A* algorithm, you could simply send out the ID of the clicked node, then perform a move method that makes use of the algorithm on all relevant clients.

View Postreaper4334, on 09 September 2010 - 02:47 PM, said:

I don't know if this is any use to you, but I came a accross this rather interesting article yesterday, I haven't read the whole thing but it seems like it might give you a little help: http://msdn.microsof...e/cc163648.aspx

[Edit] Figured I should mention that the example code on the article I posted a link to is in C#, but most of the article seems to describe the theory so it should still be pretty useful.


Thanks for the article! Didn't have a lot of plot, but it was certainly informational ;). My current project is all very high-level, working with emerging HTML5 features and Javascript (weird choice for an engine, right? My inspiration is Dextrose's Aves Engine - Check it out!), and as such, I'm not doing a whole lot of low-level stuff at the moment.

But I do enjoy building shite with Java and C++ quite a bit (which is a good thing considering it's a large part of my core coursework!) and you're totally right - that article has solid theory! I've bookmarked it, and will likely revisit it for future ventures :)

Cheers!
~KuroTsuto
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1