Hi!
Sorry for the thread, I’m sure it’s something basic, but I can’t understand the topic well. I have found some information and they say different things, it is not clear to me.
I’m making a fight game, only two players. It has to be in WebGL. One player could invite another to play a match through a link. The idea is that the player who invites is the host of the match and acts as a server.
So, I would appreciate some information on the subject, what could be my options to approach the problem, a point where to start, frameworks that can host in WebGL, etc.
Netcode cant support WebGL because WebGL uses WebSockets.
Transports are normally some kind of “wrapper” for something that can be used to connect over the internet (like the socket class or Steam Relay), so the networking solution can use them.
The advantage of doing it like this is that you can make all transports you want , and the code outside the transport doesnt have to change.
I guess netcode will use the Socket Class by default, which doesnt work on WebGL, so you will have to make a WebSockets transport or download one.
As for the hosting, the server itself cant be a WebGL build, so you will need a Azure, AWS or Google Cloud server, and when you want to host a game the player will send a rpc saying “hey, I want to host a lobby with this name”, and the server will handle it. Doing it that way has a lot of advantages:
-No port forwarding.
-Doesnt need the hosts computer ip.
-The server is full authoritative (You can give some authority to the host to do kick players), so the host cant cheat.
-Since the real game is not running on any client computer, but in a powerfull server, the preformance wont be a problem.
-Clients dont depeend on the host, and no host migration is needed, since the real host is a server on the cloud.
-Clients dont depend on how good is the internet of the host.
Not sure which library ‘Netcode’ is, I assume mlapi?
As far as I remember, they use Transports as well.
And there are a few WebGL transports available, e.g. this one from james: https://github.com/James-Frowen/SimpleWebTransport
You could probably convert this to any library which uses the Transport concept rather easily.
It’s usually just Connect/Disconnect/Send/etc.
I’m trying to connect a WebGL build as a client to a windows build as a server, I can’t figure out how to do it.
I have no problem doing the tutorials of the netcode for gameobjects. However, when i change to the WebSocket transport and a build webgl client, I can’t replicate the tutorials.
sorry, I wasn’t very clear. The NetworkManager (netcode for gameobjects) with a websocket transport doesn’t work in a webGL client build, even though the same setup works in a windows build
@thamrick No luck
Same problem, couldn’t solve it. So, I moved to Mirror (https://mirror-networking.com/) and it worked!
I could even setup a dedicated server (windows) and connect WebGL clients to it!
This is exactly what I’m trying to do with Mirror. Do you have any tutorials to redirect me in order to do this? It’s my first time tackling networking with Unity!