I haven’t read the whole forum yet, but I need an answer to this quickly… I’m hoping someone knows this. I have a local only networked game, and have the server and client working.
It’s a flight simulator, and when I instantiate an airplane, I need to have it show up on all the clients and work.
I got this partially working after following a tutorial, but there are problems. Network.Instantiate doesn’t seem to work if I use a GameObject in the scene. It has to be a prefab. I made the GameObjects (planes) prefabs, but some of the parts of the GameObject don’t show up in the prefab… don’t know why… This is problem #1.
So, I can Network.Instantiate a prefab, but if I do this from the computer that started the server, I have problems. I think it may be because I need to disable the server from responding to an Network.Instantiate. I set up an event function for OnNetworkInstantiate, but the server starting computer doesn’t seem to get this event… I did this:
void OnNetworkInstantiate(NetworkMessageInfo info)
{
Debug.Log(networkView.viewID + " spawned");
if (Network.isServer)
{
Network.RemoveRPCs(networkView.viewID);
Network.Destroy(gameObject);
}
}
So, I was thinking I would use my local Instantiate to setup a plane, then Network.Instantiate to make it on the clients… but that is bad because the NetworkView has an “Observed” transform… you plug in the prefab… but it won’t take a GameObject in the scene.
So I guess I have to use Network.Instantiate to spawn every object including the local one, but I have camera problems… This is problem #2
All the cameras on the planes are part of scripts on the planes, and I have a system them switches cameras according to the plane… The cameras DON’T FOLLOW WITH THE GAMEOBJECT WHEN I MAKE IT A PREFAB!! I don’t know why. The prefab doesn’t seem to copy more than one level down in the GameObject.
Does anyone know how I should do this? I need to control the cameras for each plane, and yet instantiate them on the network and locally. I only want to control the local plane, and have the network planes track… I thought this would be almost automatic… because it’s such a common thing, but NO… Does anyone know a solution?
Thanks