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

How to handle networking for 4 player co-op game

Discussion in 'Multiplayer' started by Roryyyyyyyyyy, Jun 8, 2015.

  1. Roryyyyyyyyyy

    Roryyyyyyyyyy

    Joined:
    Jun 8, 2015
    Posts:
    21
    So I am planning on creating a game which consists of 4 player co op missions and I am trying to find the options I have on how I will handle the networking. I have checked out photon but I am not quite sure about whether it is quite what I want.

    Ideally I would like something that allowed a player to host a game and other players connect to it, would this be possible with photon and without hamachi or anything? If not, any information/advice you have would on how best to deal with this type of thing would be greatly appreciated.
     
  2. JakeLeB

    JakeLeB

    Joined:
    Apr 18, 2013
    Posts:
    25
    I've used Photon a lot, it's a very good asset. You are able to do what you want with Photon, if you follow a few tutorials on YouTube you can learn how to Connect and spawn players in, the only down side IMO with Photon is the cost. If you're on a tight budget you'll be limited to 20 players on your game at one time, unless you pay a fee to upgrade the limit.

    As for the Hamachi question, the way Photon works is similar to Unity's inbuilt Networking, it's on a Cloud Server which means it's always up and connecting is as simple as:

    void Connect() {
    PhotonNetwork.ConnectUsingSettings("GameVersion");
    }

    That will straight away connect you to the Server, then it's as simple as setting buttons to create a Room, Find Random or even find a Room by name.
     
    tobiass likes this.
  3. Roryyyyyyyyyy

    Roryyyyyyyyyy

    Joined:
    Jun 8, 2015
    Posts:
    21
    Thankyou for your reply, in regards to what you said about the player limit, does that mean it will be limited to 20 players connected to any lobby?

    If I wanted it to connect to other peoples IP will the inbuilt unity networking do? Will that also include a charge? I am hoping that this project will get to the stage where I can actually release it, so I'm looking for the best and cheapest solution.

    Sorry for all the questions but I am trying to find the best way to go about doing this early on haha
     
  4. JakeLeB

    JakeLeB

    Joined:
    Apr 18, 2013
    Posts:
    25
    With a free License using the PhotonCloud (Their Server) you are limited to 20 connections, it doesn't matter if you create a game with 20 players per lobby, you'll only have one Lobby. Any players trying to connect when 20 slots are taken will be disconnected.

    You can host a Server yourself so the downtime would be if your server went off, for that you get 100 users.

    Once you call Connect, you're connected to the Server you can then find a Lobby and join a room, if you wanted to find a friend instead of an IP as the creator of a Room doesn't host the Server but creates and it's hosted on the MasterServer you'd have to find a Room with a name or the Masters Name.
     
    tobiass likes this.
  5. Teyhouse

    Teyhouse

    Joined:
    May 25, 2013
    Posts:
    12
    it means you can only use 20 connections in the free-edition - otherwise you have to buy a license