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

How to achieve a Host/Client relationship on WebGL

Discussion in 'Multiplayer' started by rkhadder, Mar 7, 2017.

  1. rkhadder

    rkhadder

    Joined:
    Jan 4, 2015
    Posts:
    6
    I am working on a simple turn based multiplayer game. The ideal flow is someone creates a match and someone joins their match then they play against each other. I tried to accomplish this with UNet but was surprised to see that a WebGL game cannot act as a host. I was wondering what the best way to achieve this relationship for my Unity built WebGL game?
     
  2. Karsten

    Karsten

    Joined:
    Apr 8, 2012
    Posts:
    187
    Hi,

    You need to use WebSockets, there is an option to activate it in the NetworkManager class
     
  3. rkhadder

    rkhadder

    Joined:
    Jan 4, 2015
    Posts:
    6
    Websockets don't let me host a game through webgl - it seems to let me only connect to a server
     
  4. IAMBATMAN

    IAMBATMAN

    Joined:
    Aug 14, 2015
    Posts:
    272
    yep, tried for a while with UNET and WebGL. Didn't know what to do, so I switched to Photon.
     
  5. Karsten

    Karsten

    Joined:
    Apr 8, 2012
    Posts:
    187
    Seriously, trying to host a game in a browser is a bad idea and you should take any other road possible first, why dont you run a server on a cheap windows host? You could even run a home PC with a dynamic ip service while you still develop and if your budget is zero.