[UNet] Instantiating over Network won't work
I have a multiplayer game here I need to instantiate cubes mid game, so they need to be visible on the server and clients. Currently when I try NetworkServer.Spawn it's displayed in my scene view but not in the server or client's game view, I am still able to jump on and run into the boxes though. I am pretty new to Unity so I don't really know why nothing its not showing up on my screen.
public GameObject block;
[Server]
public void GenerateTerrain()
{
Vector3 pos = new Vector3(x * 2 - 29, y * 2 - 198, z * 2 - 29);
GameObject cube = (GameObject)Instantiate(block, pos, Quaternion.identity);
NetworkServer.Spawn(cube);
}
Calling script:
if (isServer)
{
Debug.Log("Server");
Spawner = GameObject.Find("Environment");
Spawner.GetComponent<Spawner>().CmdGenerateTerrain();
}
What I see in Unity: https://gyazo.com/61b45a3494b8d81d48f01220b0ca36c5
Your answer
Follow this Question
Related Questions
Spawn prefabs according to player platform with LobbyManager 0 Answers
NetworkServer.Spawn() not being called 1 Answer
Reference lost in NetworkEntity 0 Answers
NetworkServer is not active. Cannot spawn objects without an active server. 0 Answers
[URGENT] Problem with synchronizing objects loaded from server for multiplayer 0 Answers