You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
1.0 KiB
39 lines
1.0 KiB
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;
|
|
}
|
|
}
|