29 lines
577 B
C#
29 lines
577 B
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class CameraController : MonoBehaviour
|
|
{
|
|
[SerializeField] private Transform target;
|
|
|
|
[SerializeField] private Vector2 minMaxXY;
|
|
|
|
|
|
void Start()
|
|
{
|
|
if(target == null)
|
|
{
|
|
Debug.Log("ûÕÒµ½½ÇɫλÖÃ");
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private void LateUpdate()
|
|
{
|
|
|
|
transform.position = new Vector3(Mathf.Clamp(target.position.x,-minMaxXY.x,minMaxXY.x) , Mathf.Clamp(target.position.y, -minMaxXY.y, minMaxXY.y), -10);
|
|
}
|
|
}
|