Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Is it possible to build a peer-to-peer network in Unity3D

Discussion in 'Multiplayer' started by reset, Jul 30, 2009.

  1. reset

    reset

    Joined:
    May 22, 2009
    Posts:
    393
    Hi there

    is it possible to build a peer to peer network in Unity3D - rather than a server-client network?

    thanks
     
  2. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    No
    All goes through the server

    Anything else would be a problem as anyone with a restrictive firewall would no longer be able to play as all peers in a peer 2 peer network have to setup their firewalls etc as if they were servers.
     
  3. reset

    reset

    Joined:
    May 22, 2009
    Posts:
    393
    I was hoping that the Facilitator could negotiate the connection of a computer into the network somehow.

    Just read about this group that having been exploring massive 3d p2p networks - interesting

    http://www.solipsis.org/
     
  4. reset

    reset

    Joined:
    May 22, 2009
    Posts:
    393
    I suppose what I was curious about was: if you had, say, 100 users that had all created their own 3d worlds, running on their own computers in Unity3D - could these users all connect somehow and then jump between these worlds?

    Basically a de-centralized 3D peer-to-peer setup?
     
  5. zumwalt

    zumwalt

    Joined:
    Apr 18, 2007
    Posts:
    2,287
    Nope, one simple reason, Unity will only allow a single client connect command, if you do more than one it drops the first. Also in Unity, you can only be the client or the server with its current command set.
     
  6. dgish

    dgish

    Joined:
    May 2, 2009
    Posts:
    10
    I have slightly different problem. I'm sure this is solvable using the Mono TCP/IP stack, I just don't want to reinvent the wheel if something's already out there.

    Is there a solution for ad-hoc connections where the server is simply discoverable? We only need something that works on a local LAN -- clients will all be local and I don't need NAT punch-through etc. In particular, I don't want the bother of running my own master server.

    Thanks,

    David Gish
     
  7. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    You could use the regular socket on client and server just for the use of broadcast detection and server information transfer
     
  8. sdgd

    sdgd

    Joined:
    Jan 15, 2013
    Posts:
    81
    Is this still true?

    or did they changed in to possibility to Peer to Peer?

    I'm reviving this post, because it's been 5 years till now, ...
     
  9. appels

    appels

    Joined:
    Jun 25, 2010
    Posts:
    2,687
    The networking hasn't changed in the last 4 years, yes it's still valid.
     
  10. Cains

    Cains

    Joined:
    Sep 30, 2013
    Posts:
    1
    Wouldn't it make more sense to mold networking around peer-to-peer? Then peer-to-peer would be possible and making server-client networking would be as easy as designating one of the peers as a server. Not to mention peer-to-peer is the natural way to think of networking, and Unity really makes you think you're doing peer-to-peer with the RPCs before you realize that everything goes through the server even when directed to a specific player.

    Compared to native server-client making peer-to-peer literally impossible. I mean there are a lot of valid uses for peer-to-peer in games, one thing I would love is to make it so servers could communicate with each other.
     
    Last edited: Feb 23, 2014
  11. scaroni

    scaroni

    Joined:
    Sep 21, 2012
    Posts:
    2
    Hey guys,

    You`re all saying that it`s impossible to implement p2p networking using unity networking API,
    but what if i used socket class from .Net and use it to implement my own protocol. Would it
    be possible then? I know that for online gaming the firewall would still be an issue, but it should
    work for lan, shoudn't it?

    Thanks
     
  12. sdgd

    sdgd

    Joined:
    Jan 15, 2013
    Posts:
    81
    hmmm, ...
    Scaroni, seems you can't since .Net does not have PeerToPeer class, ...

    I've just found some data here:

    http://www.youtube.com/watch?v=7bQ7Bz0MDrI

    sigh it'll take 50 years till unity will make P2P if you ask me, ...

    if we wanted to have P2P would it be possible to have it with making some Plugins?!?!?
     
  13. fholm

    fholm

    Joined:
    Aug 20, 2011
    Posts:
    2,052
    If there is a lot of demand for a real peer-to-peer solution (where there really is NO server, and all clients send all their data to all other clients), I could considering building one on top of my UdpKit library.
     
  14. sdgd

    sdgd

    Joined:
    Jan 15, 2013
    Posts:
    81
    what do you mean UdpKit library?

    how would you build P2P in unity?
     
  15. fholm

    fholm

    Joined:
    Aug 20, 2011
    Posts:
    2,052
    sdgd, i mean: I would use another networking library which works with unity, then the default one. which would allow me to build a peer-to-peer solution.
     
  16. sdgd

    sdgd

    Joined:
    Jan 15, 2013
    Posts:
    81
    hmmm, ... that would be interesting I'll be keeping a watch on that, ..

    well all I need to have is send a message over the web and recieve it I can program my self if I want to make sure the message was recieved. OR if wrong message came from wrong address, ...

    like X IP loged in and does stuff.
    than Y IP sends message same as X IP but nothing is returned to Y IP, cuz Y IP isn't loged in and no current function exist to deal with Y IP behaviour, ...


    sometimes I don't get it, ...
    Servers in a micro structure are peer to peer anyway.
    and in Macro structure they aren't.

    and what bugges me the most is why can't we do micro.

    it's kinda same as saying you can make children but you can't have sex.
     
  17. Steviebops

    Steviebops

    Joined:
    Apr 9, 2013
    Posts:
    132
    Im working on a fighting game one-on one style, and P2P seems like the way to go. It seems very odd to me that Unity doesn't support it.
     
  18. emathew

    emathew

    Joined:
    Jul 31, 2017
    Posts:
    13
    Does Unity still restrict a pure p2p network architecture?
     
  19. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    Unity doesn't have a built in high level solution designed for peer to peer. You certainly could build your own on top of the LLAPI or NetworkServerSimple though.
     
  20. FakeByte

    FakeByte

    Joined:
    Dec 8, 2015
    Posts:
    147
    You can use Unity's LLAPI to create a P2P connection. Just let every player open socket as host and then one more socket for every other player in the game. Then every player connects to each others host socket. If your game is run over the internet then you need to use a NAT faciliator though or you will run into problems.
     
    CSmith_CDOTech likes this.