Networking LoadLevel - player connect

I’ve got a lot of my networking platform in place at the moment, but when setting up my NPC/Enemy to take syncd damage (by adding a networkview component and RPC’ing the damage as per the player script) I have noticed that the enemy is reloaded for player 2. This is indicated by damage being dealt by player 1 before player 2 joins, and the enemy being at full health when player 2 joins - damage inflicted after this affects both.

I think this is because the level is being loaded for player 2 rather than “joined” - how do I have player 2 “the client” join the scene created by player 1 “the server”?

Side question: is my approach to NPCs/Enemies the correct one?

Cheers

Edit:
As per comment:

	void OnConnectedToServer(){
		SpawnPlayer ();
	}

	private void SpawnPlayer(){
		Application.LoadLevel (1);
		GameObject player =  Network.Instantiate (playerPrefab, new Vector3 (0, 0.2f, 0), Quaternion.identity, 0) as GameObject;
		player.GetComponent<Player> ().PlayerName = playerName;
	}

This is also called in OnServerInitialized();

Use RPCMode.AllBuffered this adds the RPC to the buffer(the buffer is loaded when the player joins the server)

With the new UNET functionality I can now simply spawn the enemy once as the server, and then new players just see them. Simple :slight_smile: