how to make a multiplayer game like agar.io

Hi, how to make a multiplayer game like agar.io?? I am just wondering about the multiplayer part, what do I need to learn about UNET to achieve something like it. thanks.

Your question is formulated way to broad to answer it here. I guess you do not have any advanced networking experience hence you are posting this question? Start reading into tutorials and watch videos, try out what you learned and repeat.

There are many ways to create a multiplayer experience like its done in Agar.io. The developers used an authoritative client-server environment (source) which already requires all basic features of the UNet high level API.

Basically what you should do.
Spawn objects on server using NetworkServer.spawn
Get movement commands from clients and send them to server,
Use the NetworkTransform to synch player positions (or make your own synchronization code)
Detect collision of objects on server and react based on mass.

What is your question exactly?

1 Like

im curious about the scalability when there r so many players, can unet handle it?

That’s a question of if you have a server capable of running what you need it to. Each player will use a certain amount of bandwidth, each player will need a certain amount of processing power to read in and send data out and perform collision checks and whatnot, and enough RAM to hold all the player data.

so i need to set up my own server that is not included in unet?

Hes talking about hardware. First, you need to develop your multiplayer game and try to optimize its performance to the min. Second, you have to host the game either by letting players create lobbies which are set up on their own or rent servers to host dedicated games.

Call of Duty is a good example for player-based game hosting, DotA 2 is the exact opposite, all games are hosted on central Valve servers. If you let players host by themselves on their own machines, it could well be that their bandwidth is not enough to play this game without lags and other networking problems. On the other side servers hosted by you cost money and are more complicated to set up (in comparison to player-owned lobbies).

The choice you are going for affects the capability your multiplayer game has.

Can you please tell me how I do this I’m trying to learn UNet by making small browser games, meaning I have no budget for servers and what not. So can I have the player set up a lobby? Any help would be great :slight_smile:

Yes you can, its not even that hard with UNet. You only need to disentangle all the synonyms of the gaming jargon and translate them into more professional vocabular:
A player is nothing else than a client, a peer who receives commands from a server and sends requests to it. In this case a lobby is nothing else than the server side being hosted by a client peer. So the client both controls commanding and connections of the other clients and is indeed a client by himself.

This introduces some problems like authoritative cheating by the hosting client and bandwidth limits. A normal videogame player will probably not have the high networking capacity Valve server rooms contain. Because you then have to make compromises and let the connected peers command some gameplay aspects on their own which provides chances for malicious players to cheat, wether being the hoster or not.

In general putting aside the fact that you want to host your server or use uNet’s match making to host games by players, Agar.io is not that much of a network intensive game, each game world/server/instance contains around 30 players and handling this is not a huge issue, specially considering the fact that collision detection is too simple in the game and you don’t need special complex, fancy logic to run the game.

does unet or unity provide the server?

@Ashkan_gc Well its not always ideal to use hosting servers. Client-hosted games have many positive features that can outweight the negative ones like cheating. If the players depend on servers provided by the developer they cant play when there is a maintenance and if the publisher shuts down support for the game the community will be dead. No hosting servers = No multiplayer matches.

@Exorific Not directly no. Servers to host your games on are expensive but Photon has cloud servers you can rent, of which the prices are pretty okay. There are many hosting services in the internet, Amazon Web Services is among those too. You will have to assume that providing any of these options introduces a problem of money, thats just how it is.

Ok, say I was making a small multiplayer game like agar, and I wanted 10 people to play in the same game, how do I have Client-hosted games without the relay servers or the matchmaker or anything that costs money, please help I really want to learn and practice UNET but I can’t really make games that cost any money :frowning:

I cannot help you with practical tips as I have never worked with UNet or Photon. But this question you propose here is way to broad again (“How to develop a client-hosted multiplayer game in UNet?”).

Why do other fellow network programmers need to learn this from YouTube videos and long blog posts tutorials? The answer is: Because that is the only way to really learn networking, and its not even real network development. UNet offers a high level API that makes it possible for you to not touch any even remotely complex socket and IP communication source, so just go for it, do it yourself.

In case you need to create a multiplayer game like agar.io then remembers that there are many different ways to do it. You can do it like in Agar.io game. The developers utilized a commanding client-server environment which already needs all simple features of the UNet high level API. Ensure that in the start, you have to make your multiplayer game and try to optimize its performance to the min. Then, just host the game moreover by allowing players make lobbies which are set up on their own or rent servers to host devoted games.

Call of Duty is a good case for player-based game hosting, DotA 2 is the precise opposite, and all games are hosted on dominant Valve servers. In case you allow players host by themselves on their own machines, it could well be that their bandwidth is not sufficient enough to play this game without lags and other networking issues. Apart from that, the other side servers hosted by you cost money and are more complex to arrange

This a very late reply BUT a possible solution to this (or at least minimizing the costs) is using Mirror in combination with a relay server with the library Light Reflective Mirror. Its authors change its name sometimes, it used to be called dark reflective mirror so just look around and you will find it.

Essentially it allows you to direct-connect your players in a host/client setup with NAT punch (note: it introduces issues with public wifis and company wifis tho) or alternatively just a cheap but high latency relay server.