I am a beginner who is trying to make a 2D multiplayer game using Unity, and I found an error that is difficult to solve. I have tried to find a solution but still haven't found it. can you help me? here is my code:
public class PlayerController : MonoBehaviourPun, IPunObservable
{
public float speed;
private Rigidbody2D rb2d;
public Animator animator;
public PhotonView pv;
private Vector3 smoothMove;
private GameObject sceneCamera;
public GameObject playerCamera;
// Use this for initialization
void Start()
{
rb2d = GetComponent<Rigidbody2D>();
if (photonView.IsMine)
{
playerCamera = GameObject.Find("Main Camera").GetComponent<GameObject>();
//sceneCamera = playerCamera;
sceneCamera.SetActive(false); // this is line 29
playerCamera.SetActive(true);
}
}
}
this is my code and this error message appears :
NullReferenceException: Object reference not set to an instance of an object PlayerController.Start () (at Assets/Scripts/PlayerController.cs:29)