EDIT: In addition to thr answer below, these links helped resolve the issue...
https://forum.unity.com/threads/ui-buttons-to-spawn-units-buildings.356813/ https://forum.unity.com/threads/network-spawned-objects-not-showing-up-at-other-clients.501724/
I am instantiating and parenting an object, a shot from a spaceship, which should display on all player screens. This works only when the host fires a shot. When a client fires a shot, only that client can see the shot.
For network identity, the ship (parent) is set to local player authority. For the shot, neither local or server are selected.
This is the code that creates the shot...
public class fire : NetworkBehaviour{
public GameObject shockwave;
public GameObject ship;
private GameObject eb;
private GameObject go;
private int energy = 4;
private float targetTime = 10.0f;
public override void OnStartLocalPlayer()
{
base.OnStartLocalPlayer();
gameObject.name = "Local";
}
public void createshockwave()
{
ship = GameObject.Find("Local");
Debug.Log(ship);
if (!ship.GetComponent<NetworkIdentity>().isLocalPlayer)
{
return;
}
go = Instantiate(shockwave, ship.transform.position, ship.transform.rotation);
go.transform.parent = ship.transform;
NetworkServer.Spawn(go);
}
}
Any clues as to what might cause the object to be displayed on other screens when shot by the host, but not client?