- Home /
invalid asset Id if player is connected
I'm trying to implement a small code change to the following project:
https://github.com/michaelmanus/Unet-Client-Server-Example
and in MyServer.cs I'm trying to add:
[Serializable]
public class World
{
public string StageName;
public string Message;
public List<Chests> Chests;
}
[Serializable]
public class Chests
{
public string name;
public int id;
public string pos;
}
public class MyServer : MonoBehaviour
{
void Awake()
{
Application.runInBackground = true;
NetworkServer.RegisterHandler(MsgType.Connect, OnConnect);
NetworkServer.RegisterHandler(MsgType.AddPlayer, OnAddPlayer);
NetworkServer.RegisterHandler(MsgType.Disconnect, OnPlayerDisconnect);
NetworkServer.Listen(7777);
PopulateServerEntities();
GameObject chest = Instantiate(Resources.Load("Chest"), new Vector3(5,5,5), Quaternion.identity) as GameObject;
chest.AddComponent<NetworkIdentity>();
NetworkServer.Spawn(chest);
}
everything is fine but if the player is also connected I get:
"OnObjSpawn netId: 2 has invalid asset Id
UnityEngine.Networking.NetworkIdentity:UNetStaticUpdate()"
any thoughts?
also need to mention that I have
public enum PrefabType
{
Player,
Npc,
Chest
}
set in GlobalAssets.cs
and I have a Chest prefab in my Resources folder
Comment