i get an error help me pls

Options
using UnityEngine;
using Photon.Pun;

public class CameraController : MonoBehaviourPunCallbacks
{
  public GameObject player;
  private Transform cameraTransform;

  private void Start()
  {
    cameraTransform = GetComponent<Transform>();
  }

  private void Update()
  {
    if (photonView.IsMine)
    {
      cameraTransform.position = player.transform.position;
      cameraTransform.rotation = player.transform.rotation;
    }
  }
}

NullReferenceException: Object reference not set to an instance of an objectcameracontroller.Update () (at Assets/cameracontroller.cs:18) i get this error

Answers

  • Tobias
    Options

    We can't look into your NullReferenceExceptions, sorry. Check which value is the one being null, then analyze why.