123
-=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- (c) WidthPadding Industries 1987 0|390|0 -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=-
Socoder -> On Topic -> Best way to implement network movement system?

Tue, 08 Jul 2008, 04:19
Afr0
Bah!
I've been going through this in my head for months now, and I'm just... not getting it right!

(Note: I'm using UDP)

My first idea is to have the clients send their positions to the server every 100msecs or so, and then have the server perform a bounds check on them. But this would require me to send them as reliable packets, which I've read shouldn't be neccessary when using UDP. I wanna try to save as much bandwidth as possible. Of course I could interpolate on the client and server side, but I'm just not sure if it would be accurate enough..?

Second idea is to have the client send a START_MOVEMENT packet to the server with it's current position and where it's going. Then it would receive periodic movement correction packets from the server. But this would require me to use A-Star on the server - way too much math, and difficulty in implementation!!

Any suggestions?

-=-=-
Afr0 Games

Project Dollhouse on Github - Please fork!
Tue, 08 Jul 2008, 13:37
Scherererer
what do you mean when you say 'reliable packets'? technically no packets over UDP are 'reliable' in terms of order, consistancy, etc. I don't see why you'd have to make them as such. I would just send it to the server and let the server do the bounds-check and then snap players back in that go out. Alternatively, you do bounds checking on the client side and implament a punk-buster type system that double checks downloaded content to make sure the maps don't have bounds removed by cheating tools.

-=-=-
YouTube Twitter
Computer Science Series: Logic (pt1) (part 2) (part 3) 2's Complement Mathematics: Basic Differential Calculus
Tue, 08 Jul 2008, 19:22
Orion Pax
UDP does not do reliable packets. BUT! what he is talking about is implementing his own version of RELIABLE packets into his code. The same thing was done with Blitz Play Pro. Its a UDP network userlib for blitz. I bought it some years ago just before they owner disappeared off the side of the earth.

At any rate the way I do it with the help of blitz play pro is the clients send a broadcast message too all other clients every 100ms. Its not the best secure way but it uses the least bandwidth. It works like this. 1 client sends a broadcast message of a POSITION UPDATE type to the server. The server ignores that its a position update, it just sees a broadcast message and distributes it to everyone except the author. You could make it so the server does recognize a broadcast message of positional updates and records this information per player and do some cheat detection there. Then if the server likes the info then broadcast it.
Tue, 08 Jul 2008, 21:53
Eikon
Send a 'state' packet every 100ms containing a single byte that defines all player actions (walking left, up, down, etc.). Only send an update with full player position when they are idle, or have changed from one state to another to align them. This will allow for smooth movement of clients, which is impossible if you update the position manually every packet.

Also, you'll need to come up with a routine to make packets reliable. This would include a method to discard old or duplicate packets, and a way to resend a packet until an acknowledge reply is received. Reliable packets schemes are necessary with UDP for things like connecting and disconnecting from a server.

www.eiksoft.com/multi/multi.htm

Wed, 09 Jul 2008, 10:37
Orion Pax
Now that sounds better. I might have to redo my code in my game to do that. I can see it and think of how I would work that into my game.