Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Trying to understand Unity Networking with the webplayer

Discussion in 'Multiplayer' started by bloomoog, May 8, 2014.

  1. bloomoog

    bloomoog

    Joined:
    Apr 17, 2014
    Posts:
    2
    I have a small web game that I want to make multiplayer, with 10 players in a single match. I would like to host these matches on the same server where I host my website.

    When a client starts webplayer, does the script in my gameobject that contains Network.Initialize create a server on the clients machine, or the machine that hosts my website and thus my game.unity3d file? How do I stop this from being called every time a new client goes to my website, and instead joins a game already in progress?

    How would I allow for multiple matches?

    I'm having some difficulty wrapping my head around unity's networking, so any help is appreciated!
     
  2. appels

    appels

    Joined:
    Jun 25, 2010
    Posts:
    2,687
    Hosting a server means running software on that server, not a website or webpage. A genuine application.
    When you start a server instance in the webplayer, it's hosted on the client side.
    Eh... A client needs to connect to a server that is running...
    I would start with the networking and bother about this later.
     
  3. nastasache

    nastasache

    Joined:
    Jan 2, 2012
    Posts:
    74
    Build the game as server (Network.InitializeServer, MasterServer.RegisterHost) for your kind of hosting server platform (not for web but desktop). Start it on your web host machine.
    Then compile for web (.unity3d) only as client (without Network.InitializeServer, with MasterServer.RequestHostList).
    Then your users will be able to join the game running on server, without starting servers in their names.
     
  4. bloomoog

    bloomoog

    Joined:
    Apr 17, 2014
    Posts:
    2
    Thanks nastasache, you gave me the answers I was looking for.