using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class CameraLock : MonoBehaviour
{
    public Vector2 MaxConstraint;
    public Vector2 MinConstraints;

    // Start is called before the first frame update
    void Start()
    {
        
    }

    // Update is called once per frame
    void Update()
    {
        var playerTransform = GameObject.FindGameObjectWithTag("Player").transform;
        transform.position = new Vector3(playerTransform.position.x, transform.position.y, transform.position.z);
        if(transform.position.x >= MaxConstraint.x)
        {
            transform.position = new Vector3(MaxConstraint.x, transform.position.y, transform.position.z);
        }
        if (transform.position.y >= MaxConstraint.y)
        {
            transform.position = new Vector3(transform.position.x, MaxConstraint.y, transform.position.z);
        }
        if (transform.position.x <= MinConstraints.x)
        {
            transform.position = new Vector3(MinConstraints.x, transform.position.y, transform.position.z);
        }
        if (transform.position.y <= MinConstraints.y)
        {
            transform.position = new Vector3(transform.position.x, MinConstraints.y, transform.position.z);
        }
    }
}
