Question by
nicksvorovsky · May 01, 2018 at 04:41 PM ·
c#unity 5scripting problemnetworking
uNet. Spawning objects over the network.
Hello. I've created an inventory. And i want to create ability to throw objects from inventory. So i have a problem with spawning objects. When host throws an object , clients can see it. But when client throws an object, nothing happens and the error appears in console: "NullReferenceException: Object reference not set to an instance of an object".
Objects I want to spawn have NetworkIdentity. And I added them to Registered Spawnable Prefabs in NetworkManager.
Throwing method:
[Command]
void CmdThrowing(int i)
{
GameObject obj = (GameObject)Instantiate(Resources.Load<GameObject>(item[i].pathPrefab), transform.position, transform.rotation);
NetworkServer.Spawn(obj);
}
I'm sorry if I wrote something wrong.
Comment