Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only. On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live. Read our full announcement for more information and let us know if you have any questions.

Question Major latency when switch to Webgl

Discussion in 'Multiplayer' started by xxsaleen, Feb 17, 2024.

  1. xxsaleen

    xxsaleen

    Joined:
    Mar 17, 2023
    Posts:
    2
    Hello all!

    I am trying to build a game to be playable on the web (html5) using unity. I watched a tutorial on using Photon Fusion and started building a simple game with it. When doing a desktop build the performance is incredible when running multiple instances using parrelSync. Right now I am using host mode of Fusion 1 for this and am doing it my from my personal desktop for reference sake. When I use the fusion stats overlay, you can see the client ping is incredibly good on the desktop build, but when I switch the build to be webgl and run it in a browser it becomes unplayable with astronomical ping. I thought maybe there is something in the config that needs to be changed but I have played around with all the settings on the photon config and it seems to make no difference at all for me.

    Is it possible to build a good io type game using Unity? If so, is Fusion maybe not the right technology? Is there simply project settings that need to be changed when switching to be webgl? Is it even possible that its just bad because I'm running from my personal computer which may not allow certain network traffic to pass?? Anyway, was hoping someone else on here had experience doing webgl multiplayer that could help point me in the right direction. I was thinking about switching to just do a traditional websocket app using node, but I like the power of the unity editor which gives you a lot of tools to do stuff easier.

    Screenshot of desktop instance
    upload_2024-2-17_12-50-23.png

    Screenshot of web based instance on my machine
    upload_2024-2-17_12-44-0.png
     

    Attached Files:

  2. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    7,263
    Unless the build is set up to use a relay service this means the traffic remains entirely local. To that end, 14 ms RTT is actually pretty high. ;)

    On the web however, network transfers are done via WebSockets which itself is already slowing things down a bit. And there's always either a relay or dedicated server involved, which means traffic goes from the web instance to some online server and back to your machine (and vice versa).

    Depending on where the remote server is in relation to your location as well as your Internet connection, a 750 ms RTT might be occuring. Though I'd still expect it to be in the 100-200 ms range.

    Try to figure out what the relay server is and ping that to see what your baseline latency to that server is.
     
  3. xxsaleen

    xxsaleen

    Joined:
    Mar 17, 2023
    Posts:
    2
    Ok as soon as I get back home I'll dig into this to see if I can find the relay server being used. I didn't realize the desktop build kept traffic local, I was assuming it was going out to the fusion instance for the room management stuff and relaying through that.

    At this point I started with the most basic fusion integration which just spawns a character on the screen and then listens for input and moves them.. before I got too far into it I wanted to make sure the performance online would be acceptable.

    I'm trying to build a game similar to buildRoyale.io which I assume is just a web socket and node server. It has really good performance though. I was hoping to make something similar using unity but I'm just getting hung up on the networking performance stuff so far.

    Thanks for chiming in, at this point any feedback helps because surprisingly, I just can't find much on others having posted similar issues.