How can I make a p2p multiplayer game? I would like to have a server-less multiplayer game. But then, how all the clients know each other?
Why the p2p-protocol is so famous in file transfer but not in multiplayer games?
Answer
Peer to peer games generally still have a game host. Its the game host that posts the game to the master games list and accepts new connections. Whenever the game host accepts a new client to the game it notifies all existing clients about the new client so that they can ensure they connect to the new client.
The simplest way to implement p2p is with a lobby. All clients connect to the host in a lobby (or chat room). When the host is ready the player presses start and they all enter the game at the same time (commonly used in strategy games). A more complex approach is to use "drop-in drop-out" where players can join and leave mid game, however this is a lot more complex to implement in a p2p game and requires a feature called host-migration.
A good number of games use peer to peer networking, including most strategy, sports and driving titles. Just about all Xbox360 and PS3 games use p2p networking. The client-server architecture is mostly used in first person shooter or MMO games.
Client-Server is generally easier to implement as only 1 machine has not know the entire game state, the clients are basically just renderers with some prediction to make things look smooth.
When you build a p2p engine, all clients need a full state of the game world and they all are required to stay in sync.
For more details on p2p and client-server architectures I suggest you read the following article: What Every Programmer Needs To Know About Game Networking.
And if you're new to networking in general checkout the other great articles on that site. Glenn is a networking genius.
No comments:
Post a Comment