Hi guys and thanks to be there! IHere is the situation:
Basically i start the first scene (with a NetworkManager), press a button and connect to the server.
Then i load a scene, and by pressing another button that select the SpawnPosition i load the “LoadingScene”.
Now in the loading scene i want that the players are spawned! So i got this script in “LevelLoaderGameO” witch is a empty gameobject with a NetworkIdentity setted on LocalPlayerAutorithy.
public class LevelLoader : NetworkBehaviour {
public GameObject PlayerPrefab;
public GameObject Player;
public void Start()
{
CmdSpawnPlayers();
}
[Command]
void CmdSpawnPlayers()
{
GameObject GO = Instantiate(PlayerPrefab, null);
NetworkServer.Spawn(GO);
StartCoroutine(LevelLoaderAsync(Levels.MapInGame));
}
IEnumerator LevelLoaderAsync(string LevelName)
{
AsyncOperation load = SceneManager.LoadSceneAsync(LevelName);
while(!load.isDone)
{
float progress = Mathf.Clamp01(load.progress / .9f);
Debug.Log(progress");
yield return null;
}
}
}
The problem is that when the loading scene start i got disabled the “LevelLoaderGameO”.
If i force the LevelLoaderGameO to get enabled by enabling it on the inpsector i got: Trying to send command for object without authority. Please, i’m stucked from 2 days, help me! Thanks in advance.
Just what the message says and what the documentation says.
You are trying to send a command to a object you don’t have authority to. Tbh, there is NO need for a command in this case. You should simply run the method directory on the server from the Start method. In addition, if you are not using your own Scene management system. I suggest not doing it like this, but rather use the NetworkManager’s build in methods to change scenes.