i am having a hard time to understand how i can bring my procedural generated level into the network.
players and enemies do work, based on this tutorial (Unity Learn)
the level is mainly some cubes. i tried to add NetworkIdentity to the GameObject. the script is attached to an empty gameobject.
public override void OnStartServer ()
{
buildLevel();
}
void buildLevel()
{
level = new GameObject ("Level");
level.AddComponent<NetworkIdentity> ();
NetworkServer.Spawn (theLab);
GameObject ground = GameObject.CreatePrimitive (PrimitiveType.Cube);
ground.transform.localScale = new Vector3 (10.0f, 1.0f, 10.0f);
ground.transform.localPosition = new Vector3 (0.0f, -0.5f, 0.0f);
ground.transform.parent = level.transform;
ground.AddComponent<NetworkIdentity> ();
NetworkServer.Spawn (ground);
GameObject cube = GameObject.CreatePrimitive (PrimitiveType.Cube);
cube.transform.localPosition = new Vector3 (2.0f, 0.5f, 2.0f);
cube.transform.parent = level.transform;
cube.AddComponent<NetworkIdentity> ();
NetworkServer.Spawn (cube);
}
i get the following errors in the editor (client):
OnObjSpawn netId: 2 has invalid asset Id
UnityEngine.Networking.NetworkIdentity:UNetStaticUpdate()
i tried ClientScene.RegisterPrefab on the objects, too. still the assetID remain a bunch of zeroes…
i believe there is something common which i am doing wrong because of not knowing the how to. it must be possible to create the level on the host and than pass it to all clients, right?
thanks for any input on this.