I had the same problem and figured out how to do it. It looks like you already have a solution, but it may be interesting to share some possible ways for other people in the same situation.
This is a way to do this without a camera attached to the assembly files.
I use NetworkManager to instantiate Player-prefabs. (Same as you)
I solved the problem of finding references to clone objects, allowing clones to tell the camera who they are (or what transformation belongs to them).
The player has a script:
using UnityEngine; using UnityEngine.Networking; using System.Collections; public class PlayerController : NetworkBehaviour { public override void OnStartLocalPlayer() { GetComponent<MeshRenderer>().material.color = Color.blue; Camera.main.GetComponent<CameraFollow>().target=transform;
In my main main OS (there is no camera attached to the player assembly, only the default camera). I have included the following script. It accepts the target that I initialized with prefab using the inspector.
using UnityEngine; using System.Collections; public class CameraFollow : MonoBehaviour { public Transform target;
After starting the game, each clone tells the camera who he is, so the target changes the individual clients with this line using the script player:
Camera.main.GetComponent<CameraFollow>().target=transform; //Fix camera on "me"
This way, you don’t need to create one camera for one instance of play players (I’m not sure if this has big differences in performance), and you don’t need to deactivate all cameras that do not belong to your client.
If you place the game in the editor, you can see that on one connected client there is only one camera instead of one camera (for example, when you attach it to the assembly).
I think this is a good way to use this method, you can use it to put things in it that should only apply to the local player.
public override void OnStartLocalPlayer() { }
I tried to start the game in the editor and in the assembly, and it seems to work well.