- Home /
Main Camera GetComponent doesn't work for a script?
Hey guys, im working with Photon Unity Networking and im having trouble setting the camera to the right player. at the moment I am getting an error when I am trying to use Camera.main.GetComponent. The problem is that GetComponent is not recognising the User script as a compnent at all. However it works with other components in Camera.main. Here is the line of code:
void OnJoinedRoom()
{
GameObject player = PhotonNetwork.Instantiate ("Character", Vector3.zero, Quaternion.identity, 0);
Camera.main.GetComponent<User> ().target = player.transform;
}
Comment
Your answer
Follow this Question
Related Questions
make player move in direction it's facing 2 Answers
Euler makes my look script stop... 1 Answer
Player using Dont destroy on load 1 Answer
transforming player position on input.get button down 1 Answer
Can't get transform of parent! 1 Answer