What is the best method for creating a multiplayer system?

I am not interested in UNET. I would like to get some suggestions on how I can set up multiplayer for my game.

Look for other available alternate assets.
Is not my opinion, but often Photon is proposed among few other.
You need do own research, based on what you need it for.

2 Likes

Photon is the most recommended system right now. It is primarily for small match based games and charges for CCU if you need more than the free tier. If that doesn’t fit with the game you’re creating, check out the other networking options available. The benchmark thread in the connected games forum probably has the most complete list.

1 Like

What if I wanted to create my own multiplayer system that simply tracks the position of player objects and keeps tracks of logging in and out?

php is not suitable for real time position tracking. While php can handle many quires at once, it can not guarantee, that data package has been sent received at given time. You may get some form of lag and out of syn. So this way, is hard to sync reliably any multiple positions of many players.

Potentially could be ok, if you want to store information of position in a grid. For example you got a street with houses, as you want to store information, in which house you are atm. Is a bit trivial example, but you would not have an overhead, or out of sync issues.

If you really want something own, with real time update, I suggest to look into sockets solutions.

1 Like

Are you familiar with UDP and TCP sockets? There is no reason that you couldn’t do what you want with those.

Are there any completed tutorials on how to use UDP and TCP to track player objects in multiplayer?

would it be possible to make a text file on my computer that stores player position info and have my computer act as the server?

I suggest start from asset store, then github, forum search, and finally web browser search in general. There is also dedicated forum section for network topics.

I am trying to create my own multiplayer system.
I have an Idea: would it be possible to create something on awardspace that can serve as a server and have the unity game connect to that? I used awardspace to create a login system and wonder if it can be used to create a system that can track player positions.

Don’t know, haven’t used awardspace.
And don’t know why you so focus on reinventing the wheel, which been done already many times over. There is dozen of solutions out there, with syncing etc. Even for just basics applications.

Edit
From what I see awardspace is web hosting. Not game hosting. At least not suitable for real time applications.

I have accomplished many things in singleplayer but not figured out anything for multiplayer. Sorry if it seems I’m code begging but where could I find an example of someone creating a multiplayer game using UDP? The game does not have to be anything complex just a simple first-person shooter will do.

EDIT: A good example I could use is one where the clients and servers simply send and receive data about player positions.

Asset store, github.

There are many existing networking API’s you can build on top of (Unity’s Unet has been deprecated so I recommend using a 3rd party). Or you can use C#'s socket implementation.

For sockets you can use the helper classes UdpClient, TcpClient, and TcpListener, or you can handle sockets directly. There are plenty of short examples you can find on google for these. As far as using sockets to sync positions, in Unity positions are just stored as Vector3 which is really just 3 floats. Sockets send and receive everything as a byte array so you just use the BitConverter class to convert back and forth between float and byte[ ], and Array.Copy to assemble the payload you are going to send into a single byte[ ] (you’d probably want to send all 3 floats in a single packets, and most likely other metadata about what you are sending).

Found a tutorial series starting with:

That appears to implement sockets using TcpClient and TcpListener, and looks like it gets to the actual networking part in the second video.

Do you think this is a good method?

TCP ensures the package arrival and is more error prone than UDP. However, UDP is much faster, yet you won’t get confirmation on network layer, if package has been successfully delivered. UDP is suitable for fast peaces games. Well specially was in past. This days, TCP is lighting fast. But still may introduce a little overhead. That become significant for larger data, sent over network.

So you need look, and find out what you expect, and what is your goal.

I haven’t watched the tutorial series, but it is on the topic I already suggested. Assuming TCP is appropriate for your game.

The advantage of TCP over UDP is you don’t need to worry about message reliability or ordering because it is already built into the protocol. The disadvantage is on packet loss the entire stream will pause waiting for the sender to resend. Depending on your game this can be a good thing or a bad thing.

For example, in my game the majority of packets being sent are transform updates (position, rotation, velocity, etc). These are for moving objects where I’m updating the clients several times per second. If one of these updates are dropped, my preferred behavior is to ignore the dropped packet. The server will be sending updated data again shortly anyway. TCP though doesn’t allow for that, instead TCP prevents processing of any new packets while it waits for timeout and resend of the dropped packet. So UDP is much better in my situation, with a reliability system built on top only used for the small number of important messages. YMMV

I would recommend both. TCP is usually fast, however, if it misses a packet, it’ll sit there waiting for it, and the server will resend it if it doesn’t get the ACK, which you only want if it’s something like a permanent state change. You most likely if your network drops a transform sync update, you don’t care, just get the next one, so you want UDP there.