Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Resolved Netcode callbacks are not working sometimes.

Discussion in 'Multiplayer' started by unity_Wzp0iq7iZdm0CA, Nov 23, 2023.

  1. unity_Wzp0iq7iZdm0CA

    unity_Wzp0iq7iZdm0CA

    Joined:
    Jun 20, 2020
    Posts:
    6
    Hello everyone,

    I've successfully developed a game using Netcode for game objects, allowing gameplay on the same LAN/WiFi network. Currently, the setup involves the host initiating the game, and the client entering the host's provided IP address to connect. While this is functional, I'm encountering a couple of challenges and would appreciate guidance on the following:

    1. Eliminating the Need for Manual IP Entry: I'd like to streamline the process by implementing a "Find Host" button on the client side. When clicked, this button should automatically discover and display the host's IP address, eliminating the need for manual entry.

    2. Host Availability Detection: I'm experiencing difficulties in determining whether the host is up or not. While client callbacks are working, I'm not receiving corresponding callbacks from the host. I'm seeking advice on how to effectively detect the host's status.
    I appreciate any insights or solutions you can provide to address these issues. Thank you!

    Best regards,
    Piyush (HiPolyGames)
     
  2. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    4,961
    Normally you rely on a service to do this for you. Specifically Unity Gaming Services has Lobby, Relay, Matchmaking etc

    If you want to do it yourself, you can, but it's a lot of work. At the minimum you need to have every server (host) announce themselves on a central server that you manage. Clients can check that server for available hosts. Of course you need to time out inactive servers, you need to let servers decide whether they want to be announced or not, you want to provide more info about each host such as player count, game type, etc etc. And none of this works out of the box, you have to make your own REST service. This is what makes it complicated. You may find some open source libraries that help in various areas though.
     
    unity_Wzp0iq7iZdm0CA likes this.
  3. unity_Wzp0iq7iZdm0CA

    unity_Wzp0iq7iZdm0CA

    Joined:
    Jun 20, 2020
    Posts:
    6
    Thanks for the detailed explanation. It seems like managing the server announcements and related functionalities would be quite involved if done independently. Considering this, Unity Gaming Services appears to be a more practical solution.

    I appreciate your insights and will explore Unity Gaming Services for a more streamlined approach.