School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become an Expert!

Join 307,213 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,560 people online right now. Registration is fast and FREE... Join Now!




UDP question about server control over movement

 

UDP question about server control over movement

BlackPhoenix

19 Oct, 2009 - 09:03 PM
Post #1

D.I.C Head
**

Joined: 11 Jul, 2009
Posts: 152



Thanked: 4 times
My Contributions
Hello DIC:

When using UDP protocol for games, is it better to have each player send KEYPRESSES to the server, or coordinates.

For security, I believe sending keypresses is better, for it allows the server to handle the movement of the player, will allow the server to handle collision checks, and will also completely negate the issue of having clients send modified coordinates to the server.

On the other hand, there is a great chance that the benefit of less overhead from UDP will come back in the form of the server being required to handle all movement and collision.

Should the clients handle movement and collision, or is my original idea of having the client send to the server a request to move [left and up] or [jump], etc. better?

If there are websites with full debates from programmers over how to handle these games, please send the link my way! I would greatly benefit from it. Thanks

User is offlineProfile CardPM
+Quote Post


BlackPhoenix

RE: UDP Question About Server Control Over Movement

20 Oct, 2009 - 12:39 PM
Post #2

D.I.C Head
**

Joined: 11 Jul, 2009
Posts: 152



Thanked: 4 times
My Contributions
Let's get some discussion going in here please.
User is offlineProfile CardPM
+Quote Post

pbl

RE: UDP Question About Server Control Over Movement

20 Oct, 2009 - 05:26 PM
Post #3

Java Lover
Group Icon

Joined: 6 Mar, 2008
Posts: 9,966



Thanked: 1188 times
Dream Kudos: 450
My Contributions
As this question (discussion) is not a Java question but a general game practice question (whatever the language used)
And as you can discussed UDP or not and which responsabilities should be shared between the client and the server

Topic moved to the Game forum
User is offlineProfile CardPM
+Quote Post

Aeternalis

RE: UDP Question About Server Control Over Movement

21 Oct, 2009 - 06:48 AM
Post #4

D.I.C Regular
***

Joined: 13 Jul, 2009
Posts: 273



Thanked: 25 times
My Contributions
I think you have two different issues there.

1. Yes key presses or key state should be sent to the server, Who uses it to update the players state and then sends back that information along with the rest of the world state. Game state should always be on the server, for security.

2. The two protocols commonly used in networked games are TCP/IP and UDP. For secure and guaranteed connections for purposes such as login authentication and other critical functions, use TCP because it is connection oriented, can be encrypted / secured etc.. for state updates UDP is excellent. If game state packets are lost the client can interpolate until the next packet arrives which should be relatively fast so it might even go unnoticed, but at a minimum the affect on the system will not be failure.

There were research papers done on TCP as a protocol for games and the result was not good.. mostly because the utilization of the link was low if I remember correctly. You can still find the paper on google scholar if you search under TCP game protocol.

Alot of interesting things in this area.. for instance you can use TCP and tailor your game updates sent to the client to be of a packet size less than 55 bytes or so (The size of an IP packet) that way.. the overhead of TCP (which mostly involves guaranteeing the arrival of larger chunks of data and reassembling them into the original message) is avoided, making TCP work about as fast as UDP, in a connection oriented enviornment.. win/win situation.

You can also use UDP as a connection oriented link, simply by taking on the task of parsing larger chunks programmatically into packets and reassembling them on the other side (basically taking on the responsibilities of TCP programmatically)

Now I know I simplified the responsibilities of the TCP protocol a bit.. so dont get on me about that. It's the concept I'm conveying here.


Good topic, too bad no one seems interested in talking about it.
Aet

User is offlineProfile CardPM
+Quote Post

Kanvus

RE: UDP Question About Server Control Over Movement

21 Oct, 2009 - 12:42 PM
Post #5

D.I.C Regular
Group Icon

Joined: 19 Feb, 2009
Posts: 451



Thanked: 39 times
Dream Kudos: 50
My Contributions
server doing collision detection could limit a player's ability to teleport using third party editors but as ive seen this method tried in several games, the downside is: everytime people get lag and disconnect, they reconnect at a position they were at about an hour ago because the server had to handle everything + sometimes items are lost that are recently gained.
User is offlineProfile CardPM
+Quote Post

Aeternalis

RE: UDP Question About Server Control Over Movement

21 Oct, 2009 - 01:11 PM
Post #6

D.I.C Regular
***

Joined: 13 Jul, 2009
Posts: 273



Thanked: 25 times
My Contributions
parts of that sound kind of like the game state is not being saved often enough or at a critical event.. like not saving on a forced close of the connection..

who knows..

Aet
User is offlineProfile CardPM
+Quote Post

Kanvus

RE: UDP Question About Server Control Over Movement

21 Oct, 2009 - 01:21 PM
Post #7

D.I.C Regular
Group Icon

Joined: 19 Feb, 2009
Posts: 451



Thanked: 39 times
Dream Kudos: 50
My Contributions
yes. you get 3000 exp and almost level up, then server disconnects and you come back with nothing and it happens 7 more times. these are big games by big companies too

maybe a hard problem
User is offlineProfile CardPM
+Quote Post

WolfCoder

RE: UDP Question About Server Control Over Movement

22 Oct, 2009 - 08:32 AM
Post #8

ヒヒヒー
Group Icon

Joined: 5 May, 2005
Posts: 5,256



Thanked: 30 times
Dream Kudos: 1575
Expert In: ゲームのプログラム、かわいい

My Contributions
I've never played a game like that before. Besides, that problem has nothing to do with movement.

The only time I've lost things was when the server crashed completely and they had to roll it back to last week's backup.

This post has been edited by WolfCoder: 22 Oct, 2009 - 08:33 AM
User is offlineProfile CardPM
+Quote Post

BlackPhoenix

RE: UDP Question About Server Control Over Movement

23 Oct, 2009 - 08:24 AM
Post #9

D.I.C Head
**

Joined: 11 Jul, 2009
Posts: 152



Thanked: 4 times
My Contributions
Like Wolf said, that must have been a terribly coded program, because I've never seen anything like that before.

Especially nowadays, where the game is constantly saving data, then another process is backing up that data elsewhere.


User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 11/21/09 09:57PM

Live Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month