i got my multiplayer game going but i cant seem to summon object over network.
this is my script:
using UnityEngine;
using UnityEngine.Networking;
public class networkspawn : NetworkBehaviour {
public GameObject prefab;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
if (Input.GetKey(KeyCode.Space))
{
CmdSummon(prefab, transform.position, Quaternion.identity);
}
}
[Command]public void CmdSummon(GameObject summonedprefab, Vector3 position, Quaternion rotation)
{
GameObject go = Instantiate(summonedprefab, position, rotation);
NetworkServer.Spawn(go);
Destroy(go, 10);
}
}
it works for the host but on client i get the error “trying to send command for object without authority.”
if i use network.instantiate i get the error “failed network.instantiate because we are not connected.”
any ideas?