using System.Collections; using System.Collections.Generic; using UnityEngine; public class CameraController : MonoBehaviour { public static CameraController Instance = null; public Camera MainCamera; public float MainCameraSpeed = 20; private float MainCameraMaxUp = 214; private float MainCameraMaxDown = -360; private float MainCameraMaxLeft = -194; private float MainCameraMaxRight = 220; public void Init() { Instance = this; } public void MoveMainCamera(Vector3 dir) { Vector3 moveMent = MainCamera.transform.position + dir * MainCameraSpeed * Time.deltaTime; if (moveMent.z >= MainCameraMaxUp || moveMent.z <= MainCameraMaxDown) { return; } else if (moveMent.x >= MainCameraMaxRight || moveMent.x <= MainCameraMaxLeft) { return; } MainCamera.transform.position = moveMent; } public void CameraMove(Transform pos) { MainCamera.transform.position = pos.position; } }