Search Unity

Unity Networking Code for FPS Games

Discussion in 'Connected Games' started by zencoder, Jun 5, 2009.

  1. zencoder

    zencoder

    Joined:
    Apr 20, 2009
    Posts:
    26
    I'm new to unity and have about 7 days left on my evaluation. I've played the avert fate demo and it answers my questions about AI. Unity obviously has that built in. I'm trying to see how much effort it would be to switch from Torque to Unity.

    One of the questions I have is about unity networking code. Torque has a master server concept built in and uses net masking for highly efficient client server communication.

    Torque has many scripted samples and allows you to host a multiplayer game on your computer right out of the box. The fps sample uses the garage games master server so you really don't need to touch the networking code at all. The only thing you might want to do is write your own master server if you really need one.

    From what I see in this forum is, if I switch from torque to unity I'd have to write my own networking code, or go with a single player game only. I don't think unity supports connecting to a dedicated server in the traditional client / server multiplayer game sense.

    Am I correct in this assumption or am I missing something?
     
  2. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,603
    You don't need to write your own networking code for a multiplayer game. That functionality is all present.
    Also you can decide yourself who is getting whos updates to reduce the amount of updates sent around.

    What isn't present at the time is a dedicated server.


    As for the master server: unity has comparable, potentially even more feature rich, functionality, with the difference that UT offers beta 0.1 of it freely for download on the website. For torque there are resources for it but I can't remember that the actual master server used by GG was ever made available.

    for a FPS type of game, TGEA might be better suited as this is exactly what the technology is strongly focused at.
     
  3. zencoder

    zencoder

    Joined:
    Apr 20, 2009
    Posts:
    26
    @dreamora, thanks for the information. So how does the unity networking code work in multiplayer? Pardon my ascii drawing but I think it might help. This is what I am familiar with

    1. The game client queries the Master Server for a list of dedicated servers hosting the game..

    Master Server | <---> | Game Client
    [Dedicated Server A]
    [Dedicated Server B]
    [Dedicated Server C]

    2. The game client selects a dedicated server to connect to and joins a game with other clients.

    [Dedicated Server B] <--> My client 1
    [Dedicated Server B] <--> Another Client 2
    [Dedicated Server B] <--> Another Client 3
    [Dedicated Server B] <--> Another Client 4

    3. As we play my actions and position is sent to the dedicated server which in turn sends this data to the other clients. I receive updates from the dedicated server as to the other clients player position and actions.

    How does unity work in a multiplayer example?
     
  4. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,603
    1. This is the same for Unity :)

    2/3. If you replace dedicated server with host, then this is the same as well, including the masterserver part.
    The host must not needfully be a player.

    What it isn't at the time is a headless server or dedicated server. In relation to this I would recommend to keep an eye on the Unity roadmap at http://blogs.unity3d.com/2009/04/10/unity-roadmap/ as well as the feature vote page.
     
  5. SamK

    SamK

    Joined:
    Aug 23, 2009
    Posts:
    21
    Make sure I am understanding this correctly.

    Now we can create say an FPS TDM game with unity and add multiplayer with say a lobby system and such and it can list the game players are "hosting" and other players can connect.

    What Unity does not have at this moment is a "Dedicated Server" app that can stand alone on someones PC just to run 24/7 to host the game like you could do with say COD4 and such games.

    So all in all the "host" will have to also be playing.
     
  6. immortius

    immortius

    Joined:
    Aug 7, 2009
    Posts:
    41
    That is correct. All hosts are listen servers, if you will.