Search Unity

  1. We have added dedicated sub-forums for UNet, the experimental MLAPI and Unity Transport Package. Please use the new forums to discuss related topics.
    Dismiss Notice
  2. How can our website serve you better? Give us your feedback. Take our survey and let us know.
    Dismiss Notice

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

Discussion in 'MLAPI' started by z0code0z, Mar 27, 2020.

  1. z0code0z


    Apr 10, 2018
    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


    Mar 26, 2013
  3. z0code0z


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


    Unity Technologies

    May 25, 2016
    Joe-Censored likes this.
  5. SimonVigMillard


    Jul 25, 2018
    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:

    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("", 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