- Home /
Photon unity trying to control two different player cameras over the network
hello i'm trying to control my other players camera over the network as when I join the server with the server and the first player controls both cameras here is my script. as you can see the lines of code I have atm aren't working anymore I have tired .getcomponent but that doesn't work either anyone that can help me would be so greatful.
using UnityEngine;
using System.Collections;
public class NetworkManager : MonoBehaviour {
public Transform spawnPos;
private const string version = "v0.1";
public string SurvialRoom1 = "SR";
public GameObject player;
public GameObject mainCamera;
bool connecting = false;
void Start () {
PhotonNetwork.ConnectUsingSettings(SurvialRoom1);
}
void OnGUI () {
GUILayout.Label(PhotonNetwork.connectionStateDetailed.ToString());
}
void OnJoinedLobby() {
RoomOptions roomOptions = new RoomOptions () { isVisible = false, maxPlayers = 4 };
PhotonNetwork.JoinOrCreateRoom(SurvialRoom1, roomOptions, TypedLobby.Default);
}
void OnJoinedRoom() {
Debug.Log ("Connected to Room");
SpawnMyPlayer();
connecting = false;
}
void SpawnMyPlayer() {
GameObject player = (GameObject)PhotonNetwork.Instantiate("player", spawnPos.transform.position, spawnPos.transform.rotation, 0);
((MonoBehaviour)player.GetComponent("Main Camera")).enabled = true;
((MonoBehaviour)player.GetComponent("First Person Controller")).enabled = true;
}
}
Explain in more detail what you want to achieve.
Each client usually just needs it's own camera, which might be following the character. Not all clients need to have cam's for each client.
Follow the $$anonymous$$arco Polo Tutorial and especially the part with "Fight for Control" about the cameras:
https://doc.photonengine.com/en/pun/current/tutorials/tutorial-marco-polo
Hello thank you for your reply the project I was doing had an error I restarted it and fixed the problem :)
Your answer
Follow this Question
Related Questions
Photon synchronization 1 Answer
Unable to network remove object 0 Answers
(c#) Photon networking, get players in room? 1 Answer
Using Photon to Send Screenshot to other Players 0 Answers
PhotonNetworkConnectManually Error 1 Answer