Your Code confuses me a little bit.
First, you don’t need a camera object for every prefab. You only need 1 per game. You could have more than 1 if you want… but each client will have their own copy of the one camera when the game starts.
If you really want to to keep the camera per prefab you need to Disable them at design time, then enable the camera for the active prefab you instantiate. This way, you do not have an active camera for every Network Instanciated object
Second, You are calling an RPC and in the call doing a network instanciate.
What that will do is all connected computers will spawn a Network prefab…
Sooo…
Server Starts, Calls RPC to everyone (only himself)
1 Prefab is created on the network.
Client A Starts, Gets Buffered RPC Call, Creates a Net Instanciated version of the Serves prefab
2 Prefabs
Client A then calls the Spawn RPC on everyone (Himself and the server). Both call Network.Inst
4 Prefabs
Client B Starts, Gets Buffered RPC Call, Creates a Net Instanciated version of the Server prefab, and the clients rpc prefab
6 Prefabs
Client B then calls the Spawn RPC on everyone (Himself, the server, and the other client).
9 Prefabs Prefabs
I think I said that right… I am at work, so I can’t check now. In short, every client that connects will cause all connected clients and the server to spawn another networked prefab
Try this instead:
var playerPrefab : Transform;
function Update()
{
if(Input.GetKeyDown("n"))
{
Network.InitializeServer(32, 25000);
SpawnMyPlayer()
}
if(Input.GetKeyDown("m"))
{
Network.Connect("127.0.0.1", 25000);
SpawnMyPlayer()
}
}
function SpawnMyPlayer()
{
Network.Instantiate(playerPrefab, transform.position, transform.rotation, 0);
}
OR
var playerPrefab : Transform;
function Update()
{
if(Input.GetKeyDown("n"))
{
Network.InitializeServer(32, 25000);
networkView.RPC ("SpawnPlayer", RPCMode.AllBuffered);
}
if(Input.GetKeyDown("m"))
{
Network.Connect("127.0.0.1", 25000);
networkView.RPC ("SpawnPlayer", RPCMode.AllBuffered);
}
}
@RPC
function SpawnPlayer()
{
GameObject.Instantiate(playerPrefab, transform.position, transform.rotation, 0);
}