Search Unity

Find component UNetTransport

Discussion in 'Netcode for GameObjects' started by sm5663325_unity, Nov 21, 2021.

  1. sm5663325_unity


    Sep 3, 2021
    Hello everyone! Faced a problem in the code:

    NetworkManager.Singleton.GetComponent <UNetTransport> ()

    I cannot find the UNetTransport component, although it is on the stage, what should I do in this case?

    I want to make a game where one player joins in the main menu as a host to the game stage. Another player enters the IP of the first one and also goes to the game scene. There he changes the data of the transport (perhaps this is how the connection is made, I have not yet fully understood), then, if the connection occurs, the game starts, and if it does not find the connection, then it goes to the main menu (though I didn’t understand here how to implement a check for the presence of such an ip). If anyone can help, I will be grateful
  2. ant_c


    May 22, 2019
    I am no expert on this, but I found that including this namespace allowed me to do GetComponent <UNetTransport> ()

    using Unity.Netcode.Transports.UNET;