Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Nothing works on Dedicated Server...

Discussion in 'Multiplayer' started by Slack43, Sep 8, 2018.

  1. Slack43

    Slack43

    Joined:
    Dec 23, 2015
    Posts:
    68
    Hi, i made a dedicated server in my project and nothing seems to work. In the editor while i connect to the server i get Trying to send command with object without authority. When i connect with the basic network manager hud to an local server everything works i don't get these errors.

    Script:
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEngine.Networking;
    5. using System.Text.RegularExpressions;
    6.  
    7. public class HSNetworkManager : NetworkManager {
    8.     [SerializeField]private string ipAdress;
    9.     [SerializeField] private TMPro.TMP_InputField ipInputField;
    10.  
    11.  
    12.     // Use this for initialization
    13.     void Start () {
    14.      
    15.     }
    16.  
    17.     // Update is called once per frame
    18.     void Update () {
    19.         if(Input.GetKeyUp(KeyCode.Return))
    20.         {
    21.             SetIP();
    22.         }
    23.     }
    24.     public void SetIP()
    25.     {
    26.         ipAdress = ipInputField.text;
    27.     }
    28.     public void PlayClient()
    29.     {
    30.         if(ipAdress == null)
    31.         {
    32.             print("Ip is not correct");
    33.             return;
    34.         }
    35.         print("Connecting...");
    36.         NetworkManager.singleton.networkAddress = @ipAdress;
    37.         NetworkManager.singleton.networkPort = 7777;
    38.         NetworkManager.singleton.StartClient();
    39.     }
    40.     public void StartDedicatedServer()
    41.     {
    42.         NetworkManager.singleton.networkPort = 7777;
    43.         NetworkManager.singleton.StartServer();
    44.     }
    45. }
    EDIT: NetworkManager is set to automaticaly spawn players on scene load.
     
  2. CatDoge

    CatDoge

    Joined:
    Aug 8, 2014
    Posts:
    13
  3. Slack43

    Slack43

    Joined:
    Dec 23, 2015
    Posts:
    68
    Its not attached to the player. It's a script from the main menu that lets player join or start a dedicated server. I noticed when starting a dedicated server using the StartDedicatedServer() in my code the game is not interactable, it doesn't even load the Online Scene in the network manager. The server is hosted fine but doesn't work. I think when you use these

    1. NetworkManager.singleton.networkPort = 7777;
    2. NetworkManager.singleton.StartServer();

      The scene should load in the game.
     
  4. Slack43

    Slack43

    Joined:
    Dec 23, 2015
    Posts:
    68
    Maybe there is a big latency on the server. Im hosting the server and testing the clien on same machine, and my pc is really bad.