2 Players on LAN network receive same randomly generated level

Hey there!, so, I am making a game like space invaders, but, 1 player can only move the ship, and the other one can only fire!, only problem is right now, is that the level I have is randomly generated, so that means, on player 1 screen he is dodging ships, on player 2 screen he is flying into ships, player 2 dies but not player 1,
Here is some snipets of code I have:

// Player 1 controls gun only
(NetworkManager.playerType == 0)
			{
			if (Input.GetButtonDown ("Jump")) 
				{
						Instantiate(mainBullet, transform.position + new Vector3(0f, 0f, 0.5f), transform.rotation);	                                  
	
				}
//Player 2 controls movement only
if(NetworkManager.playerType == 1)
			{
			verticalSpeed = Mathf.SmoothDamp (verticalSpeed, verticalTopSpeed * Input.GetAxis ("Vertical"), ref verticalSpeedV, verticalSpeedChange);
			horizontalSpeed = Mathf.SmoothDamp (horizontalSpeed, horizontalTopSpeed * Input.GetAxis ("Horizontal"), ref horizontalSpeedV, horizontalSpeedChange); 
			transform.position = new Vector3 (Mathf.Clamp (transform.position.x + horizontalSpeed * Time.deltaTime, -maxHorizontalPos, maxHorizontalPos), 
		                                  			 	transform.position.y, 
		                                  				Mathf.Clamp (transform.position.z + verticalSpeed * Time.deltaTime, minVerticalPos, maxVerticalPos));
			}

// The gui in my Network Manager file
void OnGUI()
{
	if(!Network.isClient  !Network.isServer)
	{	if(GUI.Button(new Rect(300, 600, 180, 20), "Start Server"))
			{
				Debug.Log ("Starting server");
				startServer ();
				playerType = 1;
			}
			
			if(GUI.Button(new Rect(300, 640, 180, 20), "Refresh Hosts"))
			{
				Debug.Log ("Refreshing");
				refreshHostList();
			}
			
			if(GUI.Button(new Rect(700, 600, 180, 20), "Solo"))
			{
				Debug.Log ("Riding solo");
				NetworkManager.playerType = 0;
				Application.LoadLevel("Main");
			}
			if(hostData != null)
			{
				for (int i = 0; i < hostData.Length; i++)
				{
					if(GUI.Button(new Rect(300, 730, 200, 30), hostData[i].gameName))
					{
						Network.Connect(hostData[i]);
						playerType = 0;
						Application.LoadLevel("Main");
						
					}
				}
			}
	}	
}

I don’t know what else I would need to show, the level has the same background and stuff, only the enemies coming down the screen are random, here is a youtube video:

(Ignore the fact that the server ship got hit more then 3 times and didnt die, it was for testing purposes)
I think setting up the lives and score would be easy?, but I don’t know about the level, is it possible? to share a random level?
I really dont want to set waves that aren’t random

Also, this is written in C# just in case anyone is wondering

I think the easiest way would be to let the server determine where to spawn the enemies and then tell the client about it (via rpc or the like).

Okay, I’m pretty new to the whole networking thing, my random enemy spawn script is this

void Update () 
	{
		transform.position = new Vector3 (Mathf.Clamp (transform.position.x + horizontalSpeed * Time.deltaTime, -maxHorizontal, maxHorizontal),
		                                 			  transform.position.y,
		                                 			  transform.position.z + verticalSpeed * Time.deltaTime);
		trackChangeHorizontal += Time.deltaTime;
		if (trackChangeHorizontal >= horizontalSpeedChange) 
		{
			horizontalSpeed *= -1f;
			trackChangeHorizontal = 0f;
		}
	}

So, would I create a new function, with that inside it, but the function be a RPC function, that sends that^ to the client?
Or would I store the positions in a variable and send it to the client?

The server determines the position and spawns it for himself and sends the position to the client.
The client then uses the position to spawn it too.

Okay thanks, also, I dont want to start a new thread for this quick question since it’s probably really easy, but I have another mode where there are 2 ships, it’s all good (besides the level not being the same which im working on, thanks for helping me) but the server only sees itself move, and the client can see both move, how do i get it so the server can see the client moving and shooting?

How are you updating each players position over network?

And do you make sure to do the networkView.isMine check so the players can only move their own ship?

I had this problem a while ago, didn’t have enough experience to fix it.
But what I would do, is int he level spawner if networkView.isServer it generates the seed that spawns the world
and sends a RPC to the other clients (RPCMode.AllBuffered for any other player that may join) that sets there world creators seed.

You can also make the clients generate the same level by making them use the same random seed. Let the server send the seed to the both clients. Set the seed

Random.seed = theSeedFromSever;

If you then take random numbers in the same way out in the both clients, you get the same sequence of random numbers in both clients and the same levels. Of course, this only works when the clients are doing exactly the same thing. When game is playing you might need to send random numbers from the server to make things work for certain.