Search Unity

  1. Check out the Unite LA keynote for updates on the Visual Effect Editor, the FPS Sample, ECS, Unity for Film and more! Watch it now!
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. Improved Prefab workflow (includes Nested Prefabs!), 2D isometric Tilemap and more! Get the 2018.3 Beta now.
    Dismiss Notice
  4. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice
  5. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

Unity Multiplayer connect to server using networkmanager.StartClient

Discussion in 'Connected Games' started by Gboy9155, May 21, 2017.

  1. Gboy9155

    Gboy9155

    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,009
    Network.Connect is the issue here: I think that's a part of the Legacy networking.
     
  3. Gboy9155

    Gboy9155

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

    JMasterChief

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