Search Unity

How do I use the MLAPI.Puncher with the MLAPI and Enet transport?

Discussion in 'Netcode for GameObjects' started by z0code0z, Mar 27, 2020.

  1. z0code0z

    z0code0z

    Joined:
    Apr 10, 2018
    Posts:
    38
    Hello all!

    This is my first time setting up multiplayer on Unity and I was planning on using MLAPI along with the Enet transport, I kind of have an idea on how to host and join using the documentation and everything seems to work but I wanted a way to allow players to join each others games without having to port forward

    essentially 2 buttons:
    Host (player hosts the server and joins the lobby to wait)
    Join (Brings up a server list showing all the servers available to join // I will probably use the MLAPI server-list module for this)

    I haven't gotten to the server list part yet but it doesn't seem too complicated on the other hand I have no idea how to allow players to join each other without the host having to port forward

    Thank you for any help and the work being done on these projects are EXTREMELY appreciated!!
     
  2. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
  3. z0code0z

    z0code0z

    Joined:
    Apr 10, 2018
    Posts:
    38
    I wasn't sure how to do that, thanks :)
     
  4. TwoTen

    TwoTen

    Joined:
    May 25, 2016
    Posts:
    1,168
    Joe-Censored likes this.
  5. SimonVigMillard

    SimonVigMillard

    Joined:
    Jul 25, 2018
    Posts:
    13
    Hope it's okay that I add a question here @TwoTen . I am trying to use MLAPI.Puncher with the Unity.Networking.Transport example implementation described here: https://docs.unity3d.com/Packages/com.unity.transport@0.8/manual/workflow-client-server.html

    The implementation in the example works great for me, but I'm not 100% sure how to add the Puncher listener. Here is what I've done:

    Code (CSharp):
    1. using (PuncherClient connector = new PuncherClient("puncher.midlevel.io", 6776))
    2. {
    3.     // Punches and returns the result
    4.     if (connector.TryPunch(IPAddress.Parse(listenerAddress), out IPEndPoint remoteEndPoint))
    5.     {
    6.         // NAT Punchthrough was successful. It can now be connected to using your normal connection logic.
    7.         m_Connection = m_Driver.Connect(remoteEndPoint); // m_Driver is a Unity.Networking.Transport.NetworkDriver
    8.     }
    9.     else
    10.     {
    11.         // NAT Punchthrough failed.
    12.     }
    13. }
    The line "m_Connection = m_Driver.Connect(remoteEndPoint);" does not compile, because it expects a NetworkEndpoint from the Unity.Networking.Transport library, rather than an IPEndPoint. Is there a way to use the IPEndPoint as a NetworkEndpoint? Or am I completely misunderstanding how to use this?
    Also, do I need to set the MLAPI.Puncher to use my Transport implementation? In the documentation it says that it uses the SlimUDPTransport by default.
     
    Last edited: Jul 1, 2021
  6. potatokiller234

    potatokiller234

    Joined:
    Aug 29, 2018
    Posts:
    2