Instantiate 2 players on network problem

My problem: I Network.Instantiate my first person controller when I initialize a server in the scene. This is controlled by me on the server. Someone else loads the same scene then connects. On connecting, their first person controller is also Network.Instantiated. Problem is that on my screen (on the server), my camera gets switched to the new controller and now I control both bodies. On the screen of the person who just connected, they are fine except they don’t see my controller that had instantiated before they connected.

Of course, I’d like to be able make it so that each person controls the controller that they instantiate and so that the second person can see the first. Thanks.

I ran into this a few days ago. Here’s some of my code:

 if (networkView.isMine) 

{

networkRigidBody.enabled = false;

GetComponent("HeadLook2").enabled = true;

GetComponent("MouseLook").enabled = true;

GetComponent("CharacterController").enabled = true;

GetComponent("MultiCharAnimController").enabled = true;

GetComponent("CharacterMotor").enabled = true;

GetComponent("FPSInputController").enabled = true;

GetComponent("NetworkView").observed = networkRigidBody;

}

else

{

name += "Remote";

GetComponent("MultiCharAnimController").enabled = true;

networkRigidBody.enabled = true;

inventoryManager.enabled = false;

Destroy(mainCamera);

}

Do you see what I’m doing? When you instantiate the network, make sure you disable everything for the other characters. You either need to make your character have everything disabled or everything enabled and enable/disable when needed. The code above shows most scripts on the character disabled and enabled when its the right networkview. Hopefully this helps someone in the future.

I solved this by turning off the camera, mouse look and player controller among other things by default. When I instantiate a player, do an if statement checking if the player is yours and if so, enable all those things.

i have the same problam but i dont understand to fix it?

I fixed this by Instantiating my player prefabs with certain things turned off, like camera and player controller (might be a few other things too). What you want to do is check the network id (or something) to see if the player is yours. If so, turn all those things on. Essentially, there will be only one player with those things turned on per client, but it will be different for each client.