Search Unity

Unity Multiplayer UNET + SteamWorks (final connect)

Discussion in 'Connected Games' started by KnightPista, Jul 12, 2016.

  1. KnightPista


    May 18, 2015

    I have implemented SteamWorks into our UNET-based project.

    As a host, I
    1. create Steam Lobby using SteamMatchmaking, and after that
    2. SteamGameServer using GS_AUTH_API. After server is started, I
    3. update lobby custom data with SteamGameServer.GetPublicIP(), so the server public IP address is stored in the lobby
    4. On the UNET side, I start server (register handlers, then configure with topology and then NetworkServer.Listen(SERVER_PORT)).

    As a client, I
    1. receive Lobby list and get server public ip from that lobby
    2. create NetworkClient and call Connect with IPEndPoint created from the server IP address and port that I got from lobby
    However, the UNET-side does not seem to be working. After client tries to connect, nothing happens and no messages are sent.

    Has anyone here successfully connected Steam with HLAPI (UNET)? Is this right way to connect NetworkClient via Steam? There does not seem to be any tutorials on this and all I got are UNET source code and steamworks documentation :).

    Thanks for help!
  2. KnightPista


    May 18, 2015
    Ok so I managed to get it working, although I'm not very happy how its done:

    From investigation I did on UNET, it's not that simple to attach to Steam including their P2P NAT layer. The problem is, when someone want to use Steam NAT or Relay servers, he need to use their packet sending/receiving API. I have found that I can override NetworkConnection TransportSend function, but receive code is in NetworkClient so I would need to override also that. I haven't found a simple way to hook on UNET packet sending/receiving to replace it with SteamGameServerNetworking.

    Instead of that I went by detour: We have bought the NAT Traversal plugin. When starting online host, I create Steam Lobby. After NAT Traversal plugin is connected to facilitator, I update Lobby data with host guid and internal/external IPs.
    When someone wants to connect, he get these data from lobby and connect to other player using NAT plugin. So Steam is only used for lobbies (or other stuff like achievements, friends, ...). Communication is done by that plugin.

    I'm not happy with this because it is not clean Steam integration. It requires 2 third party plugins to get it working. Maybe someday UNET will support Steam directly...
    akuno, thegreatzebadiah and Ozy51 like this.
  3. nocanwin


    May 7, 2009
    Welcome to the club of devs waiting for Unity networking to support Steam. They've said it's important and it's coming, but that's about it. :(

    Not to be cynical, but I think we might have another uGUI situation. I'm going to investigate switching over to Forge networking.
    Last edited: Jul 13, 2016
  4. rempelj


    Aug 3, 2013
    Xuzon likes this.