I'm making a simple little MOBA just for fun. I was making everything single-player then I realized "oh crap I should probably add multiplayer, huh."
I've never done anything with networking before, so learning how to integrate Lidgren into my game was fun and awesome. The thing is, I pretty much know the way I'm doing things is wrong, because it's not robust enough for mainstream games to use, as far as I know, but what's wrong with it?
What I'm doing is, basically, whenever a player does an action, it sends a message to the server saying "hey, I just did this thing." The server and the client are both running the same simulation. The server then sends a message to all other clients telling them that that guy did that thing.
For the most part, except in a few cases, when a player does a thing, the client assumes it's cool and goes ahead with it on its own. So when you right-click somewhere to move there, that player's client just starts moving his guy there, and then sends a message to the server telling it about it.
- Player 1 casts a spell to make him move 100% faster for six seconds
- Player 1's local client adds that buff to his Unit object
- Player 1's client sends a message to the server saying "hey I just cast this spell"
- The server makes sure he really did have enough mana to cast that spell, and if so, adds that buff to the server's copy of that Unit object
- The server sends a message to all other clients saying "hey this guy just cast this spell"
- Every other client receives the message and goes "ah okay cool," and adds that buff to their local Unit object for that player
I've been skimming through stuff to see how big games do multiplayer, and it's kind of confusing for someone who's just starting to dabble in this stuff, but it looks like the Source engine sends a packet containing all of the changes to everything in the world every tick? Again, totally new to this stuff, but can you really push that much data that frequently?
Sorry if this is a bit rambly, but basically, I was wondering why my simpler system isn't the right way to go, because if it was, other games would use it, right?