Search Unity

New network tools for a simple P2P setup?

Discussion in 'Editor & General Support' started by bigkahuna, Nov 26, 2007.

  1. bigkahuna

    bigkahuna

    Joined:
    Apr 30, 2006
    Posts:
    5,434
    I'm just starting to investigate Unity 2.01's networking capabilities and have, what I hope is, a simple question:

    How would I use Unity's new networking capabilities for a simple 2 computer, peer to peer network?
     
  2. jeremyace

    jeremyace

    Joined:
    Oct 12, 2005
    Posts:
    1,661
    You would still need a server to do that. What you can do is make one player a player-server, and have the other player connect to it.

    This isn't a limitation with Unity specifically, it's the way Raknet works IIRC, and that makes sense. We just have to do work-arounds to make the game seem like it's P2P instead of client-server.

    HTH,
    -Jeremy
     
  3. Joachim_Ante

    Joachim_Ante

    Unity Technologies

    Joined:
    Mar 16, 2005
    Posts:
    5,203
    Really if you have 2 machines, there is zero difference between server - client approaches and peer 2 peer.

    Any Unity instance can host a server and play the game at the same time.
     
  4. jeremyace

    jeremyace

    Joined:
    Oct 12, 2005
    Posts:
    1,661
    Except from a code design standpoint, you have to think in terms of client-server when planning out your code is all, how you handle prediction and lag compensation (if any) and who owns what, etc. As long as you're in the right mindset you are fine.

    -Jeremy
     
  5. shaun

    shaun

    Joined:
    Mar 23, 2007
    Posts:
    728
    I believe creating a P2P mesh style network is impossible at the moment, since we can only connect to one master peer at once. If you decide to 'grow' your P2P solution in future, you might want to consider this.
    i.e. you decide you want to run a couple of independent 'chat' sessions, or participate/poll 2 different game sessions.
     
  6. EducaSoft

    EducaSoft

    Joined:
    Sep 9, 2007
    Posts:
    650
    Don't shoot me if its not true, but using the built in networking system it is always a client connecting to a server (which might be a customer playing the game who acts as server), but with only 1 connection from each client to a server.

    If you want to open multiple connections, then I guess you would have to use raw tcp-sockets to implement your own networking system, but thats at a very low level and I also don't really know HOW to do that. Just that these functions may be available to you in mono.

    I remember having asked something before on forums about connecting to an irc server. That would have been through mono sockets instead of the networking system.