I’m creating a small test project where two players can click on the screen to add objects to a common scene. Everything works up to the spawn - the host player screen sees all of the objects for both players, but the client player screen sees none, not even the ones created from the client. Here’s the relevant code (full project attached). I think the problem is related to the fact that I am adding children to a non-player object?
GameObject _blockPanel;
GameObject BlockPanel
{
get
{
if (_blockPanel == null)
{
_blockPanel = GameObject.Find(“BlockPanel”);
}
return _blockPanel;
}
}
void Update () {
if (!isLocalPlayer) return;
if (Input.GetKeyUp(KeyCode.Mouse0))
{
var camera = MainCamera;
var worldSpot = camera.ScreenToWorldPoint(Input.mousePosition);
worldSpot.z = 0;
CmdPlayerClick(isServer, worldSpot);
}
}
Your code is hard to read, but seems like you should read through the UNET manual to understand how this whole Cmd + Spawn thing works: https://docs.unity3d.com/Manual/UNet.html
You just call a Cmd on a client, then the server runs that Cmd and there you Instantiate+Spawn the object.