Network multiplayer chess/battleship game cameras

Network multiplayer chess/battleship game cameras

I am developing a two player chess style game where one player sees his board and the other player sees their own board. They never have a view of each other’s boards. Similar to Battleship. The cameras will never move and only need to turn on when the server is started and when the client joins.

With zero background in networking, I have done the tutorials around the web about starting a server, joining as a client and moving boxes around with WASD. However, both players view is through the same camera. Any help getting two cameras to look at different things when networked would be terrific.

I am working in UnityScript.

Thank you very much in advance.

I had a similar problem in the last days.

In the scene, create a second camera. Give one camera the tag “CameraA” and the other the tag “CameraB” or something like that.

Then, in a script that is executed on level load (in the Awake function or in OnLevelLoaded or wherever it fits your structure), you do something like this:

  GameObject go = GameObject.FindGameObjectWithTag("CameraA");
  go.GetComponent<Camera>().enabled = false;
} else {
  // same thing for CameraB

I assume you have some data structure that can tell you if you are player A or B, in this case. You could make it so that the Server is player A and the Client is player B.

What I ended up doing was to instantiate a camera from a prefab in each instance of the game - sever and client. As the server was initialized I would instatiate one camera in that instance and when the client would join, I would instantiate the camera in that instance.

function activatePlayer01(){
	yield WaitForSeconds(.01);
	ScriptHolder.GetComponent(GameplayManager_N).enabled = true;
	Network.Instantiate(player, Cam01POS.transform.position, Cam01POS.transform.rotation, 0);

player being the camera prefab.