Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I once tried to write a simple game with UDP in a week as a throwaway test. It went horribly.

I threw it away early. The main problem i had was restoring the game state of all players/enemies/objects to an old state and fast forward the game to the point of time the player is playing (ie half a second before a jump. A little early or late can make the player miss the jump)

Maybe this method is not the easiest way? i suspect it to be but i designed it wrong from the beginning and realized at the end of 2nd day. (so i didnt learn too much or wasted that much time)

For myself and others, What is involved for a simple UDP game and how do i write one? Or how do i solve the prediction problem restoring to state properly.

I'll mark this as CW bc i know there will be lots of helpful answers.

share|improve this question
add comment

4 Answers 4

Glenn Fiedler has written an excellent set of articles on this, which covers pretty much all of the basic concepts.

share|improve this answer
    
The Floating Point Determinism article blew my head. Its too bad Synchronizing State isnt done because thats the one i wanted to read. Although Floating Point Determinism does answer lots of questions. –  acidzombie24 Jul 26 '10 at 11:15
    
None of those articles go in depth about state-synchronization, which is what he's asking –  BlueRaja - Danny Pflughoeft Jun 28 '11 at 22:40
add comment

Rolling your own can be educational, but you often get more done if you can leverage an existing implementation (or at least start from there).

I've used both ENet and Raknet. I only used Enet in a simple game but it did what I needed. Enet uses a lower level API than Raknet. Raknet was used in a larger project. Raknet is extremely powerful, but wants to make you structure your game around Raknet's framework.

Enet:

  • Connection Management
  • Sequencing
  • Channels
  • Reliability
  • Fragmentation and Reassembly
  • Aggregation
  • Adaptability
  • Portability
  • Freedom

Raknet:

  • Object replication
  • Autopatcher
  • Secure connections
  • Robust communication layer (basically all of Enets features rolled up in one item)
  • Remote procedure calls
  • Voice communication
  • NAT punchthrough
share|improve this answer
    
+1 for ENet, I've been using it for a while now for clients and they like it. –  Len Holgate Jul 27 '10 at 7:26
    
He is asking about state synchronization - this answer has nothing to do with that –  BlueRaja - Danny Pflughoeft Jun 28 '11 at 22:41
    
-1, same reason as BlueRaja –  Jonathan Dickinson Nov 24 '11 at 18:43
add comment

If you have the time and energy, you could download the Quake 3 source and study it. It's fairly easy to comprehend if you're comfortable with C, and equally easy to tinker with.

Which other multiplayer games have source available and use UDP?

share|improve this answer
1  
There's an article that describes the code too. trac.bookofhook.com/bookofhook/trac.cgi/wiki/Quake3Networking –  zooropa Aug 7 '10 at 1:51
add comment

If you go homebrew (as I did) you're going to learn tons - also about stuff you didn't want to know. Like NAT traversal. According to caspin, Enet is missing out on that, but you could always find some open source STUN code that works in most situations.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.