Search Unity

connect to server using networkmanager.StartClient

Discussion in 'Multiplayer' started by AnonymusRaccoon, May 21, 2017.

  1. AnonymusRaccoon

    AnonymusRaccoon

    Joined:
    Dec 3, 2016
    Posts:
    16
    Hello,

    I am triing to create a multiplayer game but now, i am stuck. I don't know what i am doing wrong, here is my code to create server and connect:
    Code (CSharp):
    1. public void CustomGameCreate()
    2.     {
    3.         NetworkLobbyManager manager = GameObject.Find("NetworkManager").GetComponent<NetworkLobbyManager>();
    4.         manager.networkAddress = "localhost";
    5.         manager.networkPort = 4444;
    6.         manager.StartHost();
    7. }
    8. public void JoinGame(string ip)
    9.     {
    10.         NetworkLobbyManager manager = GameObject.Find("NetworkManager").GetComponent<NetworkLobbyManager>();
    11.         manager.networkAddress = info;
    12.         manager.networkPort = 4444;
    13.         Network.Connect(ip, 4444);
    14.         manager.StartClient();
    15. }
    i get this error on the client when he join the server:
    The connection request to ip: port failed. Are you sure the server can be connected to?

    i have tried to remove the Network.Connect but if i do that, the client is created on the server but the player don't receive server information and can't run clientRPC.

    Sorry for my bad english.

    Thanks for reading.
     
  2. TwoTen

    TwoTen

    Joined:
    May 25, 2016
    Posts:
    1,168
    Network.Connect is the issue here: I think that's a part of the Legacy networking.
     
  3. AnonymusRaccoon

    AnonymusRaccoon

    Joined:
    Dec 3, 2016
    Posts:
    16
    Thanks, it was that.
     
  4. JMasterChief

    JMasterChief

    Joined:
    Dec 15, 2016
    Posts:
    34
    I do have a similar prob. i placed correct network address and port, but the server won't load. at all. lil gitch. glitch*