private void Awake() { if (target == null) { target = this; DontDestroyOnLoad(gameObject); } else { Destroy(gameObject); } }
private void Start() { if (Camera.main != GetComponent <Camera>()) { try { horizOffset = Camera.main.GetComponent <CameraController>().horizOffset; verticalOffset = Camera.main.GetComponent <CameraController>().verticalOffset; } catch { Debug.Log("Previous main camera did not have CameraController component, unable to retrieve offset"); } Destroy(Camera.main.gameObject); } if (player == null) { player = PlayerController.pc.controlledPawn; } tag = "MainCamera"; //distance = Mathf.Sqrt(Mathf.Pow(horizOffset, 2f) + Mathf.Pow(verticalOffset, 2f)); distance = horizOffset; targetPos = CameraTargetPos.target.GetComponent <CameraTargetPos>(); }