Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Multiplayer webgl simulator - architecture recommendation

Discussion in 'General Discussion' started by mandicLuka, Nov 3, 2020.

  1. mandicLuka

    mandicLuka

    Joined:
    Aug 20, 2018
    Posts:
    13
    Hi there,

    I am new to Unity, but I was doing game development for some time now. The first prototype of our simulator game was made with asp.net and whole frontend in html and vue.js. We are satisfied with the prototype but we have a problem with scalability and performance so we decided to give Unity a try.

    So, the idea is to have 2-6 players in a multiplayer simulation game. Frontend (rendering) for our game is pretty minimal, and we decided to use WebGL and run our client in the browser. The cross-platform solution and accessibility is a high priority.

    Since I am new to Unity, I need an advice to setup project architecture. For our simulator game we wanted to try the new DOTS in Unity. If possible, we would like to have client and server code in the same project, but build client side as a WebGL project, and server as headless.

    Networking is another issue. We don't need high level, real-time updates. Update 2-3 times per second with delta state for each player should be enough. We would like not to use third-party solutions, and UNet seems to be deprecated.
     
  2. MadeFromPolygons

    MadeFromPolygons

    Joined:
    Oct 5, 2013
    Posts:
    3,967
    Hi, I am lead developer on a major WebGL project for a client currently, and ours is networked (custom solution using AWS S3 + CloudFront) and supported thousands of users at a time. I will try to answer you as best I can.

    You will not be able to use DOTS with WebGL. You should not use DOTS in any real project yet to be honest, it is still in major flux weekly.

    WebGL is unsupported on mobile devices and a wide range of hardware. If you want cross platform and accessiblity, WebGL is not what you want at all.

    There is no inbuilt networking you can use and when there was it was terrible, you will need to (And always should) create your own solution.


    I recommend based on your questions, trying to make a small networked example in unity so you can ascertain the workload. Starting from scratch in unity without prior knowledge or experienced game programmers who know unity + networking, this is going to be a massive headache of a project for you. I recommend hiring someone experienced in WebGL + Unity + Networking if you want this to succeed.

    Good luck! :)
     
    neginfinity and Joe-Censored like this.
  3. mandicLuka

    mandicLuka

    Joined:
    Aug 20, 2018
    Posts:
    13
    @MadeFromPolygons Thank you for your response. Currently, I have set up a simple networking solution with Unity LLAPI, but since it is deprecated, I did not spend to much time on this. I just wanted to have a POC that server and client can communicate. When the time comes, we will tackle the networking with our own solution.

    The game is to be only played on PC. At the end, I have separate unity projects for server and a client, so the client can be built as a WebGL project. We have tried DOTS and its sample projects and we decided to use it only on the server side. In the next few months we will try to experiment with the setup and gain (I hope) enough experience to fairly judge whether this is a valid approach.

    P.S. A massive headache is what drives us forward. :)
     
  4. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    20,965
    Building for WebGL is one of the worst decisions you could make for a new project due to the sheer number of disadvantages that come with it. I recommend reading through the following links and be prepared to run into at least one of the limitations for each category.

    Just as an example audio has to be handled differently for WebGL and the side effect that comes with it is that it's limited to the most basic of features.

    https://docs.unity3d.com/Manual/webgl-graphics.html
    https://docs.unity3d.com/Manual/webgl-audio.html
    https://docs.unity3d.com/Manual/webgl-memory.html
    https://docs.unity3d.com/Manual/webgl-networking.html
    https://docs.unity3d.com/Manual/webgl-browsercompatibility.html

    Finally I feel it's necessary to finish this post by mentioning that I'm seeing major game engines slowly abandon WebGL. Unreal, for example, split support out of its main code base into a community-only code base. While I don't expect Unity to abandon it any time soon, I wouldn't be surprised to see it never truly improve from where it is now.

    Since you have control over the platform you are targeting I can't think of a sensible reason to choose WebGL over a native build.
     
    Last edited: Nov 13, 2020