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

public class CameraFollow : MonoBehaviour
{
    public float interpVelocity;
    public float minDistance;
    public float followDistance;
    public GameObject target;
    public Vector3 offset;
    Vector3 targetPos;

    [Header("Used for clamping cam")]
    public float minX;
    public float maxX;
    public float minY;
    public float maxY;
    
    // Use this for initialization
    void Start () {
        targetPos = transform.position;
    }
	
    // Update is called once per frame
    void FixedUpdate () {
        if (target)
        {
            /*Vector3 posNoZ = transform.position;
            posNoZ.z = target.transform.position.z;

            Vector3 targetDirection = (target.transform.position - posNoZ);

            interpVelocity = targetDirection.magnitude * 5f;

            targetPos = transform.position + (targetDirection.normalized * interpVelocity * Time.deltaTime); 

            transform.position = Vector3.Lerp( transform.position, targetPos + offset, 0.25f);*/

            if (target.activeSelf)
            {
                transform.position = target.transform.position;
            }
             /*new Vector3(
                Mathf.Clamp(target.transform.position.x, minX, maxX),
                Mathf.Clamp(target.transform.position.y, minY, maxY), 
                transform.position.z);*/
        }
        
        /*transform.position = new Vector3(
            Mathf.Clamp(player.position.x, 0.951f, 14.37f),
            Mathf.Clamp(player.position.y, -3.025999f, -0.6240011f),
            transform.position.z);*/
    }

    public void SetClampFloats(float minX, float maxX, float minY, float maxY)
    {
        this.minX = minX;
        this.minY = minY;
        
        this.maxX = maxX;
        this.maxY = maxY;
    }
}
