Hello,
I am struggling two days now. So actually I created my own lobby where the player is able to join a match through the network. The player is able to create a server(client/host) and a second one is able to join it. When the second player joined, I want that both players getting a HUD activated. I tried it with an empty gameobject with the following script:
using UnityEngine;
using System.Collections;
using UnityEngine.Networking;
public class ServerManager : NetworkBehaviour
{
public static ServerManager instance;
public GameObject CubeSelectionCanvas;
void Awake()
{
instance = this;
}
[Command]
public void CmdStartMatch()
{
RpcStartMatch();
}
[ClientRpc]
public void RpcStartMatch()
{
CubeSelectionCanvas.SetActive(true);
}
}
Furthermore the empty gameobject has an NetworkIdentity component attached with ‘Server only’.
The command is getting called by the second player, when he joins the match with: ServerManager.instance.CmdStartMatch();. Both players are getting instantiated with the NetworkManager and both have the ‘Local Player Authority’. Everytime when a client is trying to connect to the server, the following warning message is coming: ‘Trying to send command for object without authority’.
Testingwise I also added a script to my player and tried this:
public override void OnStartLocalPlayer()
{
ServerManager.instance.CmdStartMatch();
}
It is working for the Client/Host, but does not work for the normal client.
Does someone have a solution for it? Thanks in advance.
Sander