using UnityEngine;

public class CameraMover : MonoBehaviour
{
    // Start is called once before the first execution of Update after the MonoBehaviour is created
    private GameObject rat;
    public float cameraSpeed;
    void Start()
    {
        rat = GameObject.FindGameObjectWithTag("Player");
    }

    // Update is called once per frame
    void FixedUpdate()
    {
        if(rat.transform.position.x > gameObject.transform.position.x + 25)
        {
            transform.Translate(Vector3.right*cameraSpeed*Time.fixedDeltaTime);
        }
        if (rat.transform.position.x < gameObject.transform.position.x + -25)
        {
            transform.Translate(Vector3.left * cameraSpeed * Time.fixedDeltaTime);
        }
        if(rat.transform.position.y > gameObject.transform.position.y + 25)
        {
            transform.Translate(Vector3.up * cameraSpeed * Time.fixedDeltaTime);

        }
        if(rat.transform.position.y < gameObject.transform.position.y + -30)
        {
            transform.Translate(Vector3.down * cameraSpeed * Time.fixedDeltaTime);
        }

    }
}
